/r/emacs

Photograph via snooOG

The extensible, customizable, self-documenting real-time display editor.

A sub-reddit for the timeless and infinitely powerful editor and Lisp environment, Emacs.

Rules

  1. The topic is Emacs. Submissions should be on it. Comment threads may diverge, within reason.
  2. Be kind, please.
  3. If it's supposed to be funny, it should be.

Get Emacs

Emacs Resources

Emacs Tutorials

Related Subreddits

Useful Emacs configuration files and distributions

Quick pain-saver tip

/r/emacs

74,754 Subscribers

1

Still need package setup in recent emacsen?

I had good luck here fixing a problem with my init.el so I thought I'd ask about another issue. I've used package for many years now. However, I know that some time ago, it got added to the base emacs distribution. Therefore, I'm wondering if I still need the code I have in my init.el (see below) and if I needed the installed one as shown in this excerpt from Manage Packages:

use-package 20221012.1743 installed A configuration macro for simplifying your .emacs
package 1.1.0 built-in Simple package system for Emacs
use-package 2.4.5 built-in A configuration macro for simplifying your .emacs

From my initial.el. I understand some of this but I'm not great at elisp - or a programmer (unless you count SystemVerilog and some Python).

(progn
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/"))
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives '("melpa " . "https://melpa.org/packages/"))

;; from https://emacs.stackexchange.com/questions/20294/how-to-sort-packages-by-version (add-hook 'package-menu-mode-hook
(lambda () (setq tabulated-list-format
(vconcat (mapcar (lambda (arg) (list (nth 0 arg) (nth 1 arg)
(or (nth 2 arg) t)))
tabulated-list-format)))))
(package-initialize))

;; Use-Package package!
(progn
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package) )
(require 'use-package) )

0 Comments
2025/02/04
01:08 UTC

2

Match suffix in vertico?

I am a long-time ivy user but am trying out vertico and friends to see what is new on the block. But I have hit a wall with something I thought would be easy: in consult-buffer, I want to restrict to files that end in .el. However, entering "el$" matches absolutely nothing. What am I doing wrong?

2 Comments
2025/02/03
22:47 UTC

6

Location-based themes

I recently had one of those "Oh, duh!" realizations. It seems obvious in retrospect, but I haven't seen any posts about it, so I thought I'd mention it:

Themes aren't just for colors and fonts. As the documentation says, they're groups of variables that get set and unset together. So you can use them for whatever you like.

In my case, I use Emacs for personal stuff, and also at work. I like using the same init.el everywhere, but there are some settings that need to change between sites: email address, projects, git repos, and the like.

So it occurred to me that I could stick all the location-dependent stuff into a set of themes, and load whichever theme is appropriate at any given moment. And also have init.el figure out which theme to load at initialization.

I have a post about this, but the above gives you the gist.

2 Comments
2025/02/03
22:47 UTC

2

How do we version treesit grammars?

I started using treesiter major language modes in emacs. In my config, I define grammars with treesit-language-source-alist and then install them vith treesit-install-language-grammar. Then, from what I understood, packages (e.g. major modes) will specify which grammar they want to use (e.g. haskell) and if I installed a grammar under that name/symbol, it will use that grammar. It doesn't have a way to check what that grammar is or its version (except for ABI compatibility with treesit.el), it just uses the grammar under that name.

What troubles me here is that there is no way to check that grammar is of specific version. If I am a package developer and I am using haskell's treesitter grammar in my package (e.g. I am developing major mode for Haskell), I am for sure relying on the specific version of that grammar. If user uses a too different version of the grammar, be it that it is too old or too new for the installed version of my package, or maybe even a completely alternative grammar (there can be multiple haskell grammars out there), there is no way for me to detect that and to warn user about it.

Is there a general advice on how to handle this, an accepted solution?

The only robust solution I could think of is that my package specifies its own grammar. Let's say my package is called haskell-ts-mode (I started recently contributing to https://codeberg.org/pranshu/haskell-ts-mode so this is actually real example): then I would have my package do something like:

(add-to-list 'treesit-language-source-alist
	     '(haskell-ts-mode . ("https://github.com/tree-sitter/tree-sitter-haskell" "v0.23.1")))

(add-to-list 'treesit-load-name-override-list '(haskell-ts-mode "libtree-sitter-haskell" "tree_sitter_haskell"))

and it would use grammar with name haskell-ts-mode. We would probably want to make this a bit more customizable by having a variable called haskell-ts-mode-grammar that by default would have value 'haskell-ts-mode, but user could also set it to something else, in case they want to install grammar on their own or want to reuse grammar they already have installed. If they set it to haskell, they would get "typical" behaviour.

This is still not perfect, if I in the future release a version of my package that needs a version 0.24 of haskell grammar, and let's say that one is not backward compatible with 0.23, then again I have an issue -> my package can't detect that haskell-ts-mode grammar already installed on the machine is of version 0.23. Solution I can think of is to name the gramar even more specificaly: haskell-ts-mode-2 in this case, and we could increase the number each time it stops being backward compatible with the previous version. Or even go step further and directly use grammar version in the grammar name, like haskell-ts-mode-v23. One bad thing I see here is that with time there will be unused grammars installed on the user's machine.

1 Comment
2025/02/03
21:47 UTC

2

load-theme in my init.el being ignored

Hi. Long-time emacs user. Running 29.1 on both RHEL 8 and Mac (using emacsformacosx version). This should be really simple but I can't figure it out. At the end of my .emacs.d/init.el, after custom-set-variables and custom-set-faces, I have these lines:

(require 'my_theme)
(load-theme 'my_theme t)

But they get ignored when a start up emacs. If I then go to the end of each line and type c-x c-e, it works and the theme is loaded. I searched all the other files under .emacs.d and don't see any references to loading themes. What's going on?

Thanks!

8 Comments
2025/02/03
21:15 UTC

2

How to get mu4e to send from correct email address?

I have mu4e set up with three contexts. Everything generally seems to work as expected. When I compose a message, it prompts me to choose a context. The modeline changes correctly, and the "from:" header looks like what I expect. But for some reason, the messages are actually sent from the first context in my list. This is extremely annoying behavior. Does anyone have any idea why this may be happening?

2 Comments
2025/02/03
20:10 UTC

0

How old are you guys?

I feel like this sub would skew older than the average programming sub

View Poll

19 Comments
2025/02/03
19:24 UTC

1

How can I use completion to get Emacs function name in a non Elisp file?

There are times when I want to insert an Emacs function name in a file which is not an Elisp file, such as in an org document.

Is there some way to do it?

Can it be generalized to any function in any language so long as the function names are available to Emacs, somehow enabled for the file mode being edited even it is not for that programming language?

7 Comments
2025/02/03
18:14 UTC

3

Emacs 30 with use-package and vc

Hi,

I have read that Emacs 30 is adding direct support for having use-package pull packages directly from version control systems.

I have tried the following with the Pretest 30.0.93. As a newbie, I have no idea what I'm doing wrong.

(use-package org-super-links  
  :after (org)  
  :vc (:url "https://github.com/toshism/org-super-links"  
       :rev :newest  
       :branch "develop")  
  :config  
  (setq org-super-links-backlinks-into-drawer "LOG")  
  :bind (:map org-mode-map  
         ("C-c s s" . sl-link)  
         ("C-c s l" . sl-store-link)  
         ("C-c s C-l" . sl-insert-link)))  

(I do have earlier in init.el (setq use-package-always-ensure t))

What I was expecting and it doesn't actually happen is:

  • It doesn't checkout the code.
  • It doesn't load the package if I manually checked it out under ~/.emacs.d/elpa.

I'd appreciate any ideas/suggestions/hints. Thank you

7 Comments
2025/02/03
16:04 UTC

4

I can type d to see diff between buffer and file on disk when attempting to close Emacs, but now when attempting to close the buffer only (see screenshot)

1 Comment
2025/02/03
13:38 UTC

9

Hows emacs support on android - for org mode

I have kinda started using emacs org-mode for all my note-taking, though i am still on nvim for coding,

how's the emacs support for org-mode on android,

after researching for some time.I saw a f-droid version of the emacs app,

some people suggested using emacs inside termux, (but i don't wanna open like termux then emacs ,and all when i am in a public place,)

and some-people suggested using emacs with a specific port of termux from source forge, so that i can link both of them and also use the tools installed via termux on emacs,
thats the way i am thinking of using,

but before that, i just wanted to ask how are you'll doing this,

can i use my emacs config, just by using the f-droid version (here's my emacs config - i started 2 days ago dotfiles-emacs it's pretty bad, i have many things to setup for org-mode, like even org-roam and stuff)

and i am only planning on using org-mode on emacs, so how's the org-agenda notification support on the app, (can you all tell me your experiences)

i am planning on using it for managing my schedule for my life and collage

i know you all all gonna start suggesting me to use orgzly or something similar , i am trying to use orgzly-revived for 2 days, but i don't kinda like the setup , i cant edit the ui if i wished to , like relative file linking won't work and all)

btw, i am using "syncthing" to sync my files to my phone,

so can you all suggest me your setup and what you'll use ,

i know i could've kept this post short, but i kinda wanted to explain everything, thanks in advance

12 Comments
2025/02/03
12:33 UTC

1

Org-cite on wsl

Hi everyone

I'm struggling with org-cite and wsl

I've my Zotero lib on windows 10 and it do not allow me to sync a collection on my ubuntu instance

So, i'd like to sync the .bib from a windows folder with Emacs' wsl

Or maybe using zotxt ?

I currently have no clue Any help would be appreciated

Many thanks 😊

2 Comments
2025/02/03
09:23 UTC

191

All hail our new overlords /u/mickeyp, /u/github-alphapapa, and /u/Psionikus!

I woke up this morning and noticed that the list of moderators besides Zaeph has been changed to /u/mickeyp, /u/github-alphapapa, and /u/Psionikus. I for one welcome our new overlords!

Kudos to /u/Zaeph for responding to the requests of the /r/emacs community and taking action!

Also kudos to /u/jsled for your years of service, for respectfully bowing out, and for helping the transition to the new moderators.

22 Comments
2025/02/03
08:13 UTC

5

open flycheck projectile in horizontal split, instead of vertical

that's it

5 Comments
2025/02/03
03:34 UTC

0

Say goodbye to winner-mode

Winner-mode is too complicated and fails unexpectedly.

So I made a simpler one based on kys:

https://github.com/hoverwinter/kys/issues/2

19 Comments
2025/02/03
03:28 UTC

5

Multiple sideline back-end on one side, or alternative

I have a sideline config set up like this:

(use-package sideline
  :straight (:build t)
  :init
  (setq sideline-backends-left-skip-current-line t   ; don't display on current line (left)
	sideline-backends-right-skip-current-line t  ; don't display on current line (right)
	sideline-order-left 'down                    ; or 'up
	sideline-order-right 'up                     ; or 'down
	sideline-format-left "%s   "                 ; format for left aligment
	sideline-format-right "   %s"                ; format for right aligment
	sideline-priority 100                        ; overlays' priority
	sideline-display-backend-name t))            ; display the backend name

(use-package sideline-flycheck
  :hook (flycheck-mode . sideline-flycheck-setup))
  :init
  (setq sideline-backends-left '(sideline-flycheck))

(use-package sideline-eglot
  :straight (:build t :type git :host github :repo "emacs-sideline/sideline-eglot")
  :hook (eglot-mode . global-sideline-mode)
  :init
  (setq sideline-backends-right '(sideline-eglot)))

Is there any way I can have both eglot and flycheck stuff show on the right side, with egot taking precedence? Or is there an alternative to sideline that isn't as intrusive? Like showing the messages in the minibuffer (as it does by default), but with color?

1 Comment
2025/02/03
02:42 UTC

25

[Discussion] Emacs AI Assisted Programming Workflow (with aider)

When I used AI assisted programming, switch between my handwriting programming / AI programming, kind of a mess to switch context, and have to be careful of the correctness of AI to generate code.

After thinking about the process of using AI assisted programming, the current idea is probably

  1. Generate new code / modify existing functions

  2. Generate test / modification and run test / ensure that the code generated by AI is right

  3. Refactor code and test

AI-generated code is beneficial for quickly implementing features but can sometimes introduce subtle bugs or inconsistencies. That’s why Unit Test (or even more, Test-Driven Development) is critical: by writing tests before and after integrating AI-generated changes, you ensure that each incremental improvement is validated immediately. Implement your tests in small iteration steps—running your full test suite after each change—to catch issues early and maintain robust control over your codebase.

https://github.com/tninja/aider.el?tab=readme-ov-file#my-personal-development-experience-using-aiderel

AI assisted programming (in emacs) is a relatively new topic, and maybe there is no unified and mature methodology now. If you have different views or suggestions, or have new ideas, would be great if you can share in this post, Thank you.

17 Comments
2025/02/03
01:55 UTC

1

Projectile known projects file randomly being wiped.

Hi, new Emacs user trying to setup projectile and helm projectile for project management. I need help debugging 2 problems that I've ran into.

  1. Until I open a project, helm-projectile-switch-project shows an empty list. I printed the contents of the known projects file and it shows correctly the projects that were discovered previously.

  2. (Seemingly) randomly, my known projects file will be wiped. I can't really seem to find any correlation with what I do, it just happens every few times I restart emacs.

In both cases, whenever I open a fresh Emacs client, I can't instantly switch to a project which is very annoying. Here is the relevant part of my config:

(use-package projectile)
(use-package helm-projectile
  :after (helm projectile))

(with-eval-after-load 'projectile
  (projectile-global-mode)
  (setq projectile-indexing-method 'hybrid)
  (setq projectile-enable-caching t)
  (setq projectile-git-command "git ls-files -zco --exclude-standard")
  (setq projectile-project-search-path '(("~/code/" . 3) "~/dotfiles/"))
  (setq projectile-generic-command "fd . -0 --type f --color=never"))

(with-eval-after-load 'helm-projectile
  (helm-projectile-on))

If you're wondering why the configuration of the packages is separated from the installation, it's because of the way I have organized my org-files. If you have any insights on problems that might come from this way of configuring, please let me know as well.

10 Comments
2025/02/02
23:41 UTC

33

Package of the ancien world: records-mode

When I was using emacs, I used to maintain packages.

One of them was records-mode. Latest release (1.5.2) is from 2009 ! As a nostalgic emacs user, I've decided I wanted to use it again and thus, take back on maintaining and enhancing.

records-mode is a fork of notes-mode. It is meant to take notes. As simple as it is. That's not as powerful as org-mode, denote or even howm (which I really love). It is more a niche mode ;)

I tried as best I could to reimport all the past versions on my Github. It is a bit out of fashion and not very aligned with the latest developments in emacs (the code is of poor quality on top of that) but if you want to test it and give me feedback or report bugs, I am interested. Also if you have ideas to improve it or code, do not hesitate.

https://github.com/xmailla/records

Licensed under the GPL3+

2 Comments
2025/02/02
21:54 UTC

3

Post-Startup Optimizations

Hey folks! New emacs user, deeply in-love enjoying the honeymoon phase of being able to introspect every part of my editor.

But there is just one trouble! I’m noticing substantial delay before performing even little commands like C-f. I have a beefy MacBook so I don’t think it’s an underlying hardware issue. I’ve introduced a number of packages consult, cape and corfu for eglot which may be introducing delay from capf?

I was hoping to see if anyone had tips to improve and debug the performance and responsiveness of emacs after startup. Particularly in go-ts-mode!

Much appreciated much love all!

5 Comments
2025/02/02
17:40 UTC

44

New tools for long time user

I've been using Emacs for about 30 years. Not as long a some I know, but long enough to be stuck in my ways.

My configuration uses mostly built-in components, but I do regularly use the following:

Ido Flycheck or flymake (don't remember now) Projectile Magit Org mode Eglot for C Gnus Mu4e Etc Shell-mode

For those who keep up-to-date with new built-in features and add-on packages, what would you say I'm missing or should at least experiment with?

I'm not really interested in evil or doom.

Many thanks!

33 Comments
2025/02/02
13:33 UTC

0

Issue with using emacs+WSL2+VcXsrv

Title basically described the setup, I'm using emacs 29.3 and VcXsrv. I'm expecting this to work out of the box, while I'm able to have a emacs window popup under Windows with toolbars, I cannot get any text on the screen, it always shows an empty buffer. Any idea what could be the issue here?

I'm at the offical tutorial page, note that there is a scrolling bar but no text anywhere

6 Comments
2025/02/02
13:19 UTC

2

How to Find the init.el file in Void Linux

Hello guys!

I hope all of you guys are doing great. I am very new to emacs just started like a week ago and learned only the keybinding for now but i would like to customize my emacs. can someone pls tell me how to find the init.el file i read somewhere online that have to configure this file but can seem to find it and also can someone pls tell me how to to configure it properly. thanks =)

4 Comments
2025/02/02
11:58 UTC

51

Introducing my package gptel-aibo: AI Writing Assistant for Emacs

Hi everyone,

I’d like to share my Emacs package, [gptel-aibo](https://github.com/dolmens/gptel-aibo).

It is an AI writing assistant system built on top of [gptel](https://github.com/karthink/gptel) that helps users create and manage content in Emacs, including code, documentation, and even novels.

It automatically sends the content (or a portion of it) that you're currently working on as you talk to the LLM, allowing you to refer to "this function", "this class", "this file", etc. Once a response is received, you can apply it using the command gptai-apply-last-suggestions (bound to C-c !).

It also provide a quick interactive command, `gptai-complete-at-point`, which automatically inserts relevant content at the current position based on the context. For example, after writing a function comment, you can use this single command to generate the corresponding code.

The term "aibo," meaning "partner," is currently ambiguous—it could refer to gptel’s partner, or the user’s.

Hope it can be useful to some of you!

7 Comments
2025/02/02
06:22 UTC

5

How Can I Enable ALIVE LSP in Emacs?

I'm trying to get ALIVE LSP to show errors in Emacs like it does in VSCode. I started the ALIVE server, and it seems to be running and connected to Flycheck, but errors are not displaying as expected.

the log showed priority is -1 but i made sure priority is 1.

The server log confirms that ALIVE is running on port 8006, and lsp-log detects the LSP client. However, I see this warning:
Or is these any other way to show errors in emacs Dynamically?

init.el

(defvar alive-lsp-process nil "Process handle for ALIVE LSP server.")  (let ((alive-path (expand-file-name "alive-server.lisp" user-emacs-directory)))   (unless (and (setq alive-lsp-process                    (start-process "alive-lsp" "*alive-lsp*" "sbcl" "--load" alive-path))))    ;; lsp-mode の設定   (use-package lsp-mode                :ensure t                :commands lsp                :hook ((lisp-mode . lsp))                :config                (setq lsp-enable-snippet nil) ;; スニペット補完を無効化                (setq lsp-prefer-flymake nil)) ;; flycheckを使用する場合    ;; ALIVE LSP のクライアント設定   (with-eval-after-load 'lsp-mode                         (lsp-register-client                          (make-lsp-client                           :new-connection (lsp-tcp-connection (lambda () (cons "localhost" 8006)))                           :major-modes '(lisp-mode common-lisp-mode)                           :server-id 'alive-lsp                           :priority 1                           :multi-root t                           :initialization-options '(:someOption t)                           :notification-handlers (ht ("alive/notify" #'ignore))                           :request-handlers (ht ("alive/request" #'ignore))))))  ;; Flycheck を LSP で動作させる (use-package flycheck              :ensure t              :hook (lisp-mode . flycheck-mode))  ;; LSP 用に Flycheck を有効化 (with-eval-after-load 'lsp-mode                       (setq lsp-diagnostics-provider :flycheck)) ;; LSP の診断を flycheck に渡す

alive-server.lisp

bellow is log.

(ql:quickload "alive-lsp")  (alive/server::start :port 8006)

alive-lsp

SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. To load "alive-lsp": Load 1 ASDF system: alive-lsp ; Loading "alive-lsp" .

  • [2/2/2025 13:38:45][STARTING] Started on port 8006 [2/2/2025 13:38:46][INFO] Session started

lsp-log
Command "semgrep lsp" is not present on the path. Command "semgrep lsp" is not present on the path. Found the following clients for /Users/sample/play/lisp/11/format.lisp: (server-id alive-lsp, priority -1) The following clients were selected based on priority: (server-id alive-lsp, priority -1)

⛔ Warning (lsp-mode): Unable to calculate the languageId for buffer ‘format.lisp’. Take a look at ‘lsp-language-id-configuration’. The ‘major-mode’ is lisp-mode

1 Comment
2025/02/02
04:56 UTC

6

How to get org-mode to use different fonts for tables (Modus)

I’m using modus and I like Cantarell as my regular font for taking uni notes, but it doesn’t work with tables very well so I wanted to use Ioesvka for those. I’ve tried all the examples I can find online, but I can’t quite seem to get it to work

11 Comments
2025/02/02
02:23 UTC

4

"New" emacs nightly build for Fedora

Hello, ​a few days ago i found an emacs nighly/snapshot build on copr for Fedora 40/41/rawhide.

The build is based on emacs package from official Fedora repositories and built with SQLite, Tree-sitter, WEBP and XInput 2, from what I've seen only supports pgtk.

The repository ​can be considered an sucesor to this deleted repo announced here 4 years ago

Also here is the build source code if you are interested: https://gitlab.com/alternateved/bleeding-emacs

I'm not the creator or maintainer of the builds, but since I haven't seen any posts announcing it, I gave myself the task of doing it.

https://copr.fedorainfracloud.org/coprs/alternateved/nightly-emacs/

0 Comments
2025/02/02
02:11 UTC

Back To Top