Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
76
77
 
 

I'm trying to make the headers view use a smaller font size than my default. At first, I thought I could just fiddle with text-scale-set and the hooks in mu4e-headers-mode-hook, but that doesn't seem to affect the header-line. I've tried also doing a face-remap for the header-line, but when I do it that way I can't then adjust the font size further. Any advice?

78
 
 

I am happy to announce the release of Transient version 0.5.0.

More information can be found in a blog post.

Please consider supporting my work on Magit, Transient and many other Emacs packages and projects.

79
 
 

What ever org-roam command the I run I get the following error Error running timer: (error "Selecting deleted buffer").

This Doom Emacs install is on a fresh Ubuntu 22.04.3 LTS, and I have also tried Ubuntu 23.10.1 (Mantic Minotaur) and still the same error.

This is my org-roam configuration:

(use-package! org-roam
  :ensure t
  :init
  (setq org-roam-v2-ack t)
  :custom
  (org-roam-directory "~/RoamNotes")
  (org-roam-completion-everywhere t)
  (org-roam-dailies-capture-templates
    '(("d" "default" entry "* %<%I:%M %p>: %?"
       :if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n i" . org-roam-node-insert)
         :map org-mode-map
         ("C-M-i" . completion-at-point)
         :map org-roam-dailies-map
         ("Y" . org-roam-dailies-capture-yesterday)
         ("T" . org-roam-dailies-capture-tomorrow))
  :bind-keymap
  ("C-c n d" . org-roam-dailies-map)
  :config
  (require 'org-roam-dailies) ;; Ensure the keymap is available
  (org-roam-db-autosync-mode))

This is the backtrace of the error:

  set-buffer(#)
  (save-current-buffer (set-buffer buf) (org-reveal '(4)))
  (closure ((buf . #)) nil (save-current-buffer (set-buffer buf) (org-reveal '(4))))()
  apply((closure ((buf . #)) nil (save-current-buffer (set-buffer buf) (org-reveal '(4)))) nil)
  timer-event-handler([t 25958 838 237811 nil (closure ((buf . #)) nil (save-current-buffer (set-buffer buf) (org-reveal '(4)))) nil nil 85000 nil])

I have tried the following:

  • Delete the org-roam-db and then run org-roam-db-sync.
  • Going into emacsql directory >> sqlite and running make.

Thank you all in advance.

80
 
 

I'm a "Neovim Refugee" trying to get a deeper/better understanding of how emacs lisp works and how i can use it to expand on my emacs setup. I have never done anything in lisp before and still struggle to understand how single quotes signify a function or what ever.

With that said, i was also planning on doing AoC this year. Originally i wanted to look into zig or go, but now think that this might be the opportunity to dive into lisp for a bit.

But with knowing basically nothing: Is this even "viable", or advisable? Should i be looking at common lisp instead? Or would you say that's a pretty dumb idea and i should rather learn it in a different way?

81
 
 

For example, let's say I were to change backward-delete-char-untabify-method for prog-mode buffers. Naively, I'd write something like,

(add-hook 'prog-mode-hook (lambda ()
                       (setq-local backward-delete-char-untabify-method 'hungry)))

but the documentation recommends against using lambdas in add-hook calls (which makes sense). I can, of course, just make a named function instead of a lambda and pass that to add-hooks. But, rather than do that, is there any other option for setting variables automatically for modes besides a hook like this?

Also, as a bonus question, if I wanted to also do something like enable show-paren-mode for all prog-mode buffers, which of the following do you consider "better" (assume that this is not something that is likely to change frequently):

;; option 1
(defun my-prog-mode-settings ()
  (setq-local backward-delete-char-untabify-method 'hungry))

(add-hook 'prog-mode-hook #'my-prog-mode-settings)
(add-hook 'prog-mode-hook #'show-paren-mode)

;; option 2
(defun my-prog-mode-settings ()
  (setq-local backward-delete-char-untabify-method 'hungry)
  (show-paren-mode))

(add-hook 'prog-mode-hook #'my-prog-mode-settings)

Obviously, I realize that it's not really important, but I feel like bike-shedding this morning.

82
 
 

Imagine selecting a paragraph and having ChatGPT automatically correct grammar and spelling errors, then seamlessly replacing it in your buffer. Well, imagine no more - it's now a reality!

Here's what it does:

  • Selects the current paragraph in Emacs.
  • Sends it to ChatGPT for a grammar and spelling check.
  • Replaces the original text with the corrected version, all within Emacs.

Inception:

The other night I read a post on X that said LLMs would be used to enhance word prediction for texting on phones. I thought another interesting application would be to easily bring spelling and grammar fixes to whatever I'm editing in emacs.

It's not flawless, but in my experience, it's all I need.

Here's a video example: https://youtu.be/hrhoNE2M9Qw

Here's the gist: https://gist.github.com/ckopsa/c55bf8cc25df8a4a87c6993bdce3573e

Leverages chatgpt-shell found here: https://github.com/xenodium/chatgpt-shell

83
84
 
 

Hi, basically it is working well but I want to remove repetitive msg when evaluated to REPL.

for instance, when below code

nums = [1, 2, 3, 4, 5]
def double(x): return x * 2
list(map(double, nums))

is evaluated by C-c C-c

>>> 
__PYTHON_EL_eval("nums = [1, 2, 3, 4, 5]\ndef double(x): return x * 2\nlist(map(double, nums))", "/Users/darren/Work/ace/pyth/codi/01-iterations/binary-gap.py")
[2, 4, 6, 8, 10]

Can I remove this msg?

__PYTHON_EL_eval("nums = [1, 2, 3, 4, 5]\ndef double(x): return x * 2\nlist(map(double, nums))", "/Users/darren/Work/ace/pyth/codi/01-iterations/binary-gap.py")

So it just shows like

>>> 
[2, 4, 6, 8, 10]

Thanks in advance!

85
 
 

Is there a package that provides : commands like evil-ex, but without the rest of evil-mode? I'm specifically interested in regexp replacement :s/old/new/g style.

If not I'll write one

86
 
 

Just found a quick way to have tags always right aligned, taking advantage of font-lock and display property.

(add-to-list 'font-lock-extra-managed-props 'display)
(font-lock-add-keywords 'org-mode
  `(("^.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
     (1 `(face nil
          display (space :align-to (- right ,(length (match-string 2)) 3)))
        prepend))) t)
87
 
 

Hey there,

So I know if emacs is lagging I should run the profiler for a bit while it's lagging and then review the report. However, I'm not sure what to do next.

It looks clear that company / completion is responsible for the laggy behavior here, especially a jsonrpc-request made by completion. That makes sense, there's a slow network call somewhere in the works that's gumming things up.

I'm using eglot for lsp and would expect that would be the source of a slow jsonrpc call, maybe eglot trying to get completion candidates on every keystroke through the LSP server? But I don't understand the stack here well enough to know how to proceed in debugging or fixing things.

Would love any help. Knowing what to fix is great - but also I'm really interested in knowing how to know what to do next in general in this scenario.

Thanks!

https://preview.redd.it/9rbx4pm5ty2c1.png?width=1843&format=png&auto=webp&s=974bbb907f702dc775a1ef2bd34dffebc0809554

88
 
 

I just wanted to say thanks to /u/txgvnn for writing the terraform-doc package.

I find accessing Terraform provider documentation on the web to be a little cumbersome, and have often wished for a plain text experience similar to info manuals instead.

I recently decided to Google possible solutions, only to discover that /u/txgvnn had already written a package for it.

Thanks! I think it's awesome! 🙂

89
 
 

For my hobby desktop c/c++ projects I started using emacs, and I really like it. I made my own config, which contains only a couple of packages like vertico, lsp-mode, company etc.

Professionally I am an embedded systems consultant, working with lot of different uC-s and IDE-s. I have a bigger job currently where I have to work with PIC32 uC, and the project is created with MPLAB X IDE. I wanted use emacs and lsp-mode, but it seems that clangd could not find some of the headers. I have generated the compile_commands.json with a python script called compiledb, but it is not working properly.... maybe clangd can not understand some of the compile flags from xc32-cc ? (the mplab compiler).

Anyone tried this stuff? Thx for help.

90
 
 

Have you ever wanted to write a blog:

  • contained in a unique org file,
  • rendered with only one Emacs command,
  • that can be modified by writing Emacs Lisp code (and CSS too),
  • with "html templates" that are plain Emacs Lisp data,
  • with no config file,
  • and no dependencies on external static site generators?

If so, you might be interested in one.el a simple Static Site Generator for Emacs Lisp programmers and org-mode users.

👉 https://github.com/tonyaldon/one.el

👉 https://one.tonyaldon.com

👉 https://emacsconf.org/2023/talks/one/

91
 
 

I would like to select the whole function by going to VISUAL mode and using $ to go to the last character and then going to the matching bracket with %. Doing this in NORMAL mode works fine, but when in VISUAL, it doesn't. How can I fix this? Or, what should I check to fix this?

92
 
 

Had a situation this arvo when I had to pair program with someone and I forgot to bring my mouse to work. Having to run startx and then start vscode is a bit jarring and a line-of-thought breaker for me.

93
 
 

Which is a bit of a pain. Without restarting Emacs (how does one even do that 🤣) I have to upcase-char or insert-quoted "C" to get a capital 'c'.

I have no idea what combination of keys I've hit to effect this change, but it does not happen on start-up.

Viewing lossage is not much help because quite a lot of time may have passed and my need to type "C". (I am not Carl Carlson Chairman of the Classic Car Confabulation Committee. )

Does anyone have any ideas how even to debug this? I am flummoxed.

Many thanks!!


There is nothing funky about my keybindings…

(keymap-global-set "C-="     #'text-scale-increase) 
(keymap-global-set "C--"     #'text-scale-decrease)
(keymap-global-set "C-z"     #'undo-fu-only-undo) ;; suspend-frame
(keymap-global-set "C-S-z"   #'undo-fu-only-redo) 
(keymap-global-set "C-v"     #'yank) ;;  scroll-up
(keymap-global-set "C-x C-r" #'eval-print-last-sexp)
(keymap-global-set "C-s"     #'isearch-forward-regexp)
(keymap-global-set "C-r"     #'isearch-backward-regexp)
(keymap-global-set "C-M-r"   #'query-replace-regexp)
94
 
 

I'm puzzled. Whenever I do a package-refresh-contents or whenever I try to launch mastodon.el (M-x mastodon) my #emacs hangs. package-refresh-contents only shows 'Contacting host: elpa.gnu.org:443' and doesn't do much more. I have to ctlr-g to break out or wait a couple of minutes before emacs says that the package refresh is done. mastodon.el is a different beast. After a wait I get 'Wrong type argument: stringp, nil'.

Thing is, this does not happen when I'm on the vpn for work!

My two other computers at home experience the exact same issue. These two don't have any vpn software installed, just plain debian. The computer with the vpn is a Windows 10 with WSL2 running debian as well. I use cntlm when on the vpn and I set my proxy accordingly. On my plain debian home boxes I don't use any proxy. I use the same .emacs file on all three machines.

Was it a debian apt-get update that did this to me? I have no idea. Anyone here with a similar issue?

95
 
 

I've been using org-mode for my personal notes/wiki and have quite a few files across a handful of folders. They keep on growing.

Scenario:

I'm sitting in dired and want to rename a file. How does one do that again...? I know I've made notes on this before, but I can't remember which file in which folder. I remember I tagged it with :dired:, though.

What would be the fastest way to search for this? Is there a way to do a search like rename tag=dired, or similar, in a folder w/subfolders, across all my org-mode notes?

I should also mention that I really don't want to install any extra packages for this.

96
 
 

this is my current config for agenda

          (agenda ""
                  ((org-agenda-skip-function
                    '(org-agenda-skip-entry-if 'deadline)
                    )
                   (org-agenda-skip-function
                    '(org-agenda-skip-entry-if 'regexp "\\* DAILY")
                    )
                   (org-agenda-prefix-format " %i  %-12:c [%-2e] %?-12t% s")
                   (org-deadline-warning-days 0)
                   (org-agenda-start-day "0d")
                   (org-agenda-span 'day)
                   ))

there is empty agenda heading every 2 hours (8:00, 10:00, 12:00, etc until 20:00)

https://preview.redd.it/80euw3opiu2c1.png?width=1508&format=png&auto=webp&s=16c09d47b7efbeb44f67cf05d71d4582ade8a6ef

97
 
 

Hi all, I thought I was being very clever by creating a virtual machine build environment so I didn't have to litter my main computer with 100s of packages to build emacs. So I built it in a gnomebox and set the prefix to $home/.local/opt/emacs as I saw someone do. It runs fine in the virtual machine

The issue is now, I'd like to move the install or the built files to my host machine and run it, but it won't run. If I just try to move the $home/.local/opt/emacs folder to my own computer, and run it I get the following:

./emacs-29.1.90: error while loading shared libraries: libgpm.so.2: cannot open shared object file: No such file or directory

When I try to move the whole directory (source code and the build directories inside there) out of the virtual machine into the Host and try to run make install (this is after make and compilation completed) it says

make install
if [ -x ./config.status ]; then	\
     ./config.status --recheck;	\
else				\
     ../configure --cache-file=/dev/null; \
fi
/bin/sh: line 4: ../configure: Permission denied
make: *** [Makefile:573: config.status] Error 126

I have tried to chown -R : ./ to the whole directory but it still gives me the permission denied.

Any ideas how I might accomplish this task?

Thanks!

98
 
 

I wrote a few functions to improve my research workflow and easily add ArXiv papers to my library, hopefully you'll find it useful. I am aware of `arxiv-citation`, I couldn't get it to work, perhaps I did something wrong. I also added a few extra options.

https://gist.github.com/ndrwnaguib/fe7245ca5b2e8ba21b05a44679fc6148

https://i.redd.it/jgmfkyve9s2c1.gif

99
100
 
 

Hi all, I'm moving towards Emacs as an old vim user, with the goal of giving up my heathen C ways in favor of Lisp.

Attempting to use slime on a fresh install gives the error: Eager macro-expansion failure: (wrong-number-of-arguments (3 . 4) 2)

wth is this? ):

view more: ‹ prev next ›