/r/emacs

Photograph via snooOG

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

A sub-reddit 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

Related Subreddits

Useful Emacs configuration files and distributions

Quick pain-saver tip

/r/emacs

73,643 Subscribers

1

Org-capture with :prepend resets cookie

I have this org-capture template:

(setq org-capture-templates
      '(("t" "Todo"
         entry (file+headline "/my/path/notes.org" "Heading")
         "* TODO %^{Heading}"
         :prepend t)
        ))

When I use it and hits finish, this:

* Heading [1/2]
** TODO Old entry 1
** DONE Old entry 2

Ends up looking like this:

* Heading [0/0]
** TODO New enty
** TODO Old entry 1
** DONE Old entry 2

That is, the statistics cookie is being reset. This only happens when the :prepend property is true. Is this a bug or am I doing something wrong?

EDIT: It persists after upgrading to org-mode 9.7.16

EDIT 2: Adding this to the org-capture-template fixed it:
:before-finalize org-update-parent-todo-statistics

0 Comments
2024/12/04
13:08 UTC

9

Weekly Tips, Tricks, &c. Thread — 2024-12-04 / week 49

This is a thread for smaller, miscellaneous items that might not warrant a full post on their own.

See this search for previous "Weekly Tips, Tricks, &c." Threads.

Don't feel constrained in regards to what you post, just keep your post vaguely, generally on the topic of emacs.

0 Comments
2024/12/04
08:15 UTC

16

Email providers that still work reasonably with Emacs?

For <reasons> I have been looking at setting up Emacs as my mail reader again, using it with my Gmail account. rmail is my all-time favorite mail reader, but I could live with Gnus as well.

But it looks to me like Gmail has made it so difficult to set things up now, with oauth2 and whatever else -- I just want to weep thinking of losing another week of my life trying to figure it all out.

So, I'm wondering, are there any email providers -- free would be nice, cheap would be ok -- that still work relatively easily with Emacs that people could recommend? I gather Microsoft's Outlook email has gone the same route as Gmail, so not that. It could be IMAP or heck, even POP3, if that still exists.

28 Comments
2024/12/04
03:15 UTC

0

Emojis not working

I installed doom emacs on my windows machine, but the emojis arent showing up. How can I fix this?

https://preview.redd.it/cgt0rvvneq4e1.png?width=1920&format=png&auto=webp&s=f50fc1a2eac319caa62bd91b8fac7a5c7bbf7147

6 Comments
2024/12/04
01:06 UTC

1

Managing backup files

I was thinking there are a few functions for managing backup files that would be nice to have, such as opening a backup file corresponding to the file you're visiting, switching a file to numbered backups, and saving a backup file at intervals (rather than only the first save since that file was visited). I don't think this is built in. Is there a package that provides this sort of thing?

5 Comments
2024/12/04
00:12 UTC

0

Why cannot we use `async-start' for turning on a mode globally?

Why does the following block of code not work?

(require 'async)
(async-start
  (lambda ()
    (global-auto-revert-mode 1))
  'ignore)
4 Comments
2024/12/03
21:12 UTC

3

js-pkg-mode: A minor mode for working with javascript/typescript projects. Supports multiple package managers

Hello!

I just finished the work on `js-pkg-mode`. It is a fork of npm-mode with added support for all modern javascript package managers and runtimes:

  • npm
  • yarn
  • pnpm
  • deno
  • bun

Project page: https://github.com/ovistoica/js-pkg-mode

Functionality:

  • running scripts
  • adding/packages
  • installing/uninstalling dependencies
  • initiating projects

Hope you find it useful!

1 Comment
2024/12/03
19:49 UTC

4

Is it safe to use packages which load data from company Servers?

I am wondering if it is safe to use packages like magit or lab.el which operate on confidential data of my company. Any comments?

17 Comments
2024/12/03
19:03 UTC

3

Trying to troubleshoot the wallabag.el package!

(I'll admit, I'm an emacs newbie!)

I set up doom emacs last night and added the wallabag.el package as well as:

emacs-request and emacsql.

For Wallabag, I think I've added the username, password, and API info correctly, in the use-package.el file.

But when I try to load wallabag, I get the following response:

symbol's function definition is void: emacsql-sqlite

I'm too green with emacs to properly troubleshoot this! And the github for the package isn't very active, so I'm hoping for some tips or ideas here!

(The github of the package in question: https://github.com/chenyanming/wallabag.el)

9 Comments
2024/12/03
18:13 UTC

0

Does the way Emacs terminal utilities are designed mean that backgrounded shell processes started in them continue to run when Emacs is closed?

When you start a long running process like long-running-process.sh & in terminal packages liketerm, vterm and eat will they continue to run when the terminal is exited (which they should) and/or Emacs is shutdown?

If they do will that because that is inherent in the shell system?

6 Comments
2024/12/03
18:05 UTC

3

How to change color of inactive line numbers ?

I am using a themed doom emacs but the color of the inactive line numbers is too dim for me. Where could I change that ?

2 Comments
2024/12/03
15:11 UTC

4

Work with GitHub Actions in Emacs

We have recently started to migrate from Jenkins to GitHub Actions. I'm in the process of learning GH Actions and testing things out. I would very much like to view job logs in Emacs, so I tried to find a package for this, but did not succeed. Using the gh command line tool is not really an alternative either. I also looked through the Magit Forge documentation to see if Magit Forge had any tools for this, but I didn't find anything there either.

Does anyone work with GH Actions from within Emacs?

8 Comments
2024/12/03
14:52 UTC

1

Treesitter Multiple Languages

Hey all!

I'm having a bit of trouble getting syntax highlighting working for graphql string literals in a `tsx-ts-mode` buffer.

I want to get string like const gqlString = gql\query Foobar(....) {....}`` with graphql syntax.

I've been hacking on this for a while, and so far have:

(defun me/add-typescript-font-lock ()
  (setq-local treesit-font-lock-feature-list
              '((comment declaration definition)
                (keyword string escape-sequence type variable)
                (constant expression identifier number pattern property)
                (operator function bracket delimiter)))
  (setq-local treesit-range-settings (treesit-range-rules
                                      :embed 'graphql
                                      :host 'tsx
                                      :local t
                                      ;;:offset '(1 . -1)
                                      "((call_expression function: (identifier) @_fn arguments: (template_string) u/capture) (#equal @_fn \"gql\"))"))
  (setq-local treesit-language-at-point-function #'me/treesit-language-at-point-tsx))

(add-hook 'tsx-ts-mode-hook 'me/add-typescript-font-lock)

Treesitter seems to be parsing the buffer and treesit-node-at seems to be giving me the what I expect, but I still don't have the syntax highlighting. Does anybody have any example of something similar I can learn from?

Cheers!

0 Comments
2024/12/03
13:34 UTC

1

Emacs not detecting "C-M->" key press?

Hello I have the following code I am trying to get working

(use-package back-button
  :bind (("C-M-<" . back-button-global-backward)
         ("C-M->" . back-button-global-forward)
         ("C-<" . back-button-local-backward)
         ("C->" . back-button-local-forward)))

But the only keybind not working in this list is C-M->. Even if I press describe-key (C-h k) and then try to type "Ctrl + Alt + Shift + ." nothing happens so it's like Emacs doesn't detect it.

Note pressing "Ctrl + Alt + Shift + ," does successfully call back-button-global-backward.

EDIT: Not an emacs issue, turns out that key combination is being eaten by some higher process than emacs, not sure what though

Has anyone successfully tried to map this key sequence?

4 Comments
2024/12/03
12:35 UTC

84

Which EmacsConf 2024 Talks Have Your Attention?

https://emacsconf.org/2024/talks/

Which things are you excited about and what's your take on why we should pay attention?

I'll jump into the comments to avoid measuring my own biases :D

If any presenters need my video making packages, dslide and Master of Ceremonies (mc) are both up to date now on my Github! Dslide is on both MELPA and Non-GNU MELPA and is reasonably stable.

49 Comments
2024/12/03
01:50 UTC

4

How to automatically narrow to subtree when visiting an org agenda item

I am trying to write code that would help me automatically narrow to the subtree when I visit a heading using Tab in org-agenda.

As a tentative approach, my thinking is that it would involve adding a hook to the org-agenda-goto function. So I wrote the following code:

(add-hook 'org-agenda-goto 'org-narrow-to-subtree 90 nil)

However, it does not work, and I think I might be doing something wrong: When I visit a heading using Tab in the org agenda, it still shows me the whole file instead of just the subtree.

Would be grateful for any suggestions. Thank you!

8 Comments
2024/12/02
19:16 UTC

0

magit issues

Whenever I invoke magit, I get the following error.

Turning on magit-auto-revert-mode...done
require: Symbol’s value as variable is void: git-commit-filename-regexp

The error goes away if I re-install the package, but re-appears if I restart emacs.

The following is my use-package configuration for magit.

(use-package magit
  :config
  (add-to-list 'display-buffer-alist
               '("magit-diff.*"
                 (display-buffer-below-selected)
                 (window-height . 0.5)
                 (dedicated     . t)))
  :ensure t)

I would appreciate any help to resolve this issue.

Strangely, the error goes away if I load the files git-commit.el and magit-status.el!

7 Comments
2024/12/02
15:30 UTC

1

"Workspace" functionality in a SINGLE Emacs instance with bells and whistles, akin to DEs / WMs

hello! i'm looking for something rather specific, and wanted to ask you guys if you knew of any packages or ways of doing this that would help me

first, i'm gonna try and define a workspace. i talk about the workspaces commonly used in stuff like XFCE, i3 and so on, where certain apps are tied to certain workspaces, or are only accessible from this workspace. say you have firefox on workspace A, and a music player on workspace B. you only have access to and can use firefox in workspace A, and same for the music player in workspace B, but you can very easily switch between the workspaces by using a keybind, for example.

i note that my use of workspaces is to isolate apps depending on what the use case is. for example, i will separate apps in a "Working" workspace where i need to be productive, and a "Fun" workspace where i moreso have stuff like Steam, a chat app and so on.

i would like to be able to replicate this workspace feature, inside of a single Emacs frame (as working with multiple frames will quickly overwhelm me and it'll be hard to know which frame is tied to which use case).

i would also like those workspaces to have rather specific behaviors with buffers and windows :

  • like with the example of firefox and the music player, i would like to be able to isolate buffers to a specific workspace. this way, instead of having about 25 buffers i can auto-complete from when trying to switch buffers in workspace A, i can have, say, 10 for workspace A that are relevant for the workspace's purpose, 10 for the other workspace, and etc...

  • easily add buffers from one workspace to another

  • automatically send specific buffers to a pre-defined workspace, and still being able to move those buffers if i need to. for example, i'd like to send music-related buffers, like those that bango.el will create, into an "Utilities" workspace

  • as a bonus, maybe make it so whenever i open emacs for the first time in a session, specific buffers are already opened for specific workspaces, and would even have a pre-configured window configuration? such as the Utilities workspace already having the Bango Library buffer opened as a master stack, and two other windows open on the right side stacked on one another

do you guys know of any packages and set-ups that would let me do this?

thank you for reading, and have a great day :]

TL;DR : looking for an Emacs package/config that lets me simulate workspaces in a single frame. with it, i would hopefully send specific buffers to workspaces of my choosing, automate this process for specific buffers through my init.el, and possibly have specific buffers and window configurations, for different pre-made workspaces, already opened and ready whenever Emacs is launched

5 Comments
2024/12/02
15:12 UTC

12

DESIGN REVIEW: hexl-inspect -- A minor mode for hexl providing inspection data

Well I think I banged this into shape pretty well as a first Elisp project. It certainly does what I want it to do so far though it's kind of ugly. I got a lot of good advice from this thread particularly from /u/arthurno1 for details on Elisp memory, strings, garbage collection, and coding patterns.

I absolutely welcome any sort of expert commentary in style, substance, and aesthetics. I was kind of winging this, one window open on the elisp.pdf reference manual banging things out in the other window.

So without further to-do: hexl-inspect

This package implements a minor mode named hexl-inspect-mode to be used in conjunction with a buffer set to hexl-mode. When activated, the minor mode will create a data inspection buffer, window, and display to the side of the hexl-mode buffer. As the point moves around in the parent buffer, the contents will update to reflect the point’s position.

The mode depends on the variable state of hexl-inspect--big-endian-p which determines how the data under the point is to be interpreted.

The automated update structure and the mode structure was patterned after the explore mode in treesit-explore-mode in treesit.el as that was the closest analog to what I was attempting to accomplish.

EDIT: Fixed the keymap bug. I was using defvar and I was sure that was working before, but clearly not. The define-minor-mode macro for :keymap worked when I found a good example, so that's sorted.

9 Comments
2024/12/02
14:22 UTC

2

Could anyone help me setting up yasnippet and company-mode?

I was trying to setup yasnippet with company-mode. I tried installing them separately and using :with company-yasnippet in company backends. It actually works this way, but it has an issue after expansion. Usually, after expansion, some part of the snippets are selected by default which can be replaced by only typing any charecter or word. But in my case, instead of replacing that selected portion, it is prepending the characters I am pressing to already existing characters. Below is an example with python file where the pass keyword is selected after expanding a snippet. when I press a it prepends a to pass making it apass instead of replacing pass with a. Could anyone help me with this?

`pass` is selected after snippet expansion

pressing `a` appends `a` to `pass` making it `apass`

expected behaviour

2 Comments
2024/12/02
06:30 UTC

11

Prevent Dired from opening many buffers?

Have been using Dired more lately, but I find it inconvenient that it creates all these buffers when I browse around my file system. I checked dired-single, but that doesn't seem to work. I also use dired-subtree and dired-preview.

21 Comments
2024/12/02
11:42 UTC

8

List directory trees for given commit with Magit

Is there a way to:

Lists directory trees associated with the current revision allowing subdirectories to be descended or ascended and file blobs to be viewed.

Like the tree view of Tig [1]?

[1] https://github.com/jonas/tig/blob/master/src/tree.c

4 Comments
2024/12/02
10:30 UTC

0

What is the current state of coding assistants in Emacs?

I do wonder what will happen to Emacs over time as things like Codeium's Windsurf proliferate. If you think coding assistants aren't going anywhere, download that one and try it out.

These tools generate entire project structures and populate the code from a single prompt. They then, if you want, refactor multiple files to accomplish a next prompt. The performance of several hours of work in less than a minute do mean that employers, for one, will require the use of these tools. And so will most hobbyists.

What is on the horizon (or already here) for Emacs in this area?

I'm getting nervous. I want to keep using Emacs, but I am unsure that I will be able to.

22 Comments
2024/12/02
06:58 UTC

3

Is there a way to have calfw-org display only certain items from my org-agenda, such as those that have a specific tag? Like I can normally do in custom agenda views.

3 Comments
2024/12/02
02:33 UTC

10

Best practices: developing on top of modern elisp packages

I've gone through the basic materials (EINTR, manual) for developing with emacs lisp. I understand the basics. I can do basic hacks here and there. But I'm disappointed in the ratio of code I write to the functionality I can add. Most packages I use aren't built on bare emacs lisp: consul, vertico, hydra, projectile, ivy, helm, transient.

Are there write-ups or other resources on how to start emacs lisp projects to develop a lot more effectively? Sorry if this is vague -- I'm having trouble starting to penetrate how more complex emacs projects can be built.

25 Comments
2024/12/01
21:55 UTC

10

Keyboard remapping in meow

No matter their differences, one thing that unites Vim and Emacs is that both have their most-used key in an awkward position on modern keyboards 😂

Back when I was first trying out Doom, I remapped caps lock to be esc; later on, when I switched to vanilla keybinds, I remapped it to C- instead. Now, I'm giving meow a spin, and really enjoying it! Beacon is awesome, and the god-mode-like keypad offers a lot of what I liked about Doom's keymaps, but requiring essentially zero configuration.

One thing I am curious about is how other meow users are remapping their keyboards, or changing the example qwerty bindings. I'd like to keep capslock as C-; one of the things I like about meow is that the vanilla keybinds are always there for you, and so there are still a lot of things that I want to use C- for--C-s/C-r come to mind, of course, as well as C-u.

However, when you're editing with meow, it has a vim-like reliance on escape again, which has been kicked out of the prime real estate on the capslock key and relegated once again to the corner of my keyboard. This means that I can either put esc on capslock so I can exit insert mode while I'm editing, but need to reach awkwardly any time I want to use a default keybind with C-, or I can put C- on capslock and use vanilla keybinds just fine, but reach awkwardly every time I want to exit insert mode.

I'm especially surprised that discussions like this don't seem to mention this double-reliance on C- and escape and what people are doing to mitigate it. Anyone got any cool, ergonomic strategies in order to that are viable on normal qwerty keyboards?

5 Comments
2024/12/01
21:23 UTC

11

Sharing code: Readeck annotations in Emacs

The intersection of Emacs and Readeck users might be small, but I'd like to share some code I put together.

Readel: import Readeck annotations into Emacs. https://github.com/EFLS/readel/

Readeck is a self-hosted read it later service (see https://readeck.org), similar to Wallabag, Pocket, or (the now discontinued) Omnivore.

I wanted to more easily import my highlights (called annotations in Readeck) into Emacs, in Org-mode in particular, so I used request.el and the Readeck API to automate this process.

It's the first time I use a REST API, and the first time I use request but I'm glad to have something that works (and in Emacs Lisp at a level I can understand). The code is very basic, but I'm happy to share it here with others who might be interested.

2 Comments
2024/12/01
19:34 UTC

Back To Top