Per-window buffer ordering?
This is something that has bothered me for many years now, but I was always too lazy to dig in. Well, this time I'm at least not too lazy to ask:
Is there a way to make Emacs buffer ordering be per-window and remembered separately for each window?
The way I work is using eyebrowse to create "screens" or "workspaces" (I used escreen before eyebrowse, a long time ago). Each of these is usually further separated into windows. That means that certain buffers naturally end up "belonging" in certain workspaces. For example, my Clojure REPL always lives in screen 4.
This setup is great, but the way buffer switching works doesn't play nice with it. If I jump from screen 1 to screen 4 and back to 1, my previous buffer will be my REPL, which is not what I want. Screen 1, and more specifically, the window in that screen that I'm working in, should remember which buffers were used in it recently, so that I can use previous-buffer/next-buffer predictably.
I think I would expect all other buffers (ones not visited in that window) to be appended at the end, as I don't want to limit myself. I might want to switch to some of those some day.
Does something like this exist? Is it possible at all?
https://redd.it/1barvo2
@r_emacs
Is it possible to get a yasnippet expansion inside of a word ?
For example is it possible for a yasnippet key pw to expand to \^{} even if one writes bpw and not b pw ?
https://redd.it/1baepcr
@r_emacs
Getting org-archive work along with org-done
I want to write a function that marks my todo item done then archive it.
My current config is:
```
(add-hook 'org-after-todo-state-change-hook 'org-done-and-archive)
(defun org-done-and-archive ()
(interactive)
(when (and (or (equal org-state "DONE") (equal org-state "KILL"))
(org-archive-subtree-default)
)))
```
However, I cant get it to work along with org-log-done. The function would archive the todo item then add logbook to the next item. Can anyone help me out?
https://redd.it/1baas2h
@r_emacs
elispdoc - a javadoc like mechanism for elisp files
There was a recent thread about writing org mode init files where I noted that tangling an org file doesn't fit my workflow due to several considerations I'm going to leave aside here but I like having a nicely formatted documentation file for sharing.
Basically what I wanted was a way to postprocess my elisp files (primarily init.el but in theory any one) and generate either markdown or org that looked similar to literate programming examples that I could then publish if desired on github etc.
I didn't find anything that fit my scenario so I went ahead and wrote a fairly simple proto-package at
https://github.com/benleis1/elispdoc
I haven't figured out publishing yet and its still in beta stage but you can clone and load-file it to try it out. Already the output is pretty enough for my purposes.
I auto-generated the readme.md on the repo using elispdoc on itself.
I'm hoping someone else will find this useful and I'm interested in any feedback.
​
https://preview.redd.it/9l3jc18wk6nc1.png?width=1102&format=png&auto=webp&s=d1e096d4cb398c8b8fb301de37df7f480b227a9f
https://redd.it/1ba0a53
@r_emacs
Calling company-complete from a function that then continues doing other things
I would like to be able to write a bunch of functions that call `company-complete` and then continue doing things after I've selected the completion. The idea is to pretend `company-complete` has been called from inside a `\ref`.
This is a simple example
(defun f1 ()
(interactive)
(insert "\\ref{}")
(backward-char)
(company-complete)
;; now choose the completion, etc
(backward-char 4)
(insert "i_used_to_be_a_"))
If the above worked, I'd be using `company-complete`as if it was being called from a `\ref`, but then I'd modify the `\ref` to, in this example, `\i_used_to_be_a_ref`.
The problem is that the above immediately modifies `\ref`, but I never get to choose the completions . I've tried variations of the above, like `call-interactively`, without success. I think I am missing something very obvious (emacs lisp novice here).
Why do I want to do this? Because I want to use `company-complete` for arbitrary macros in latex as if they were `\ref`. I can do this modifying `company-reftex`'s `company-reftex-labels-regexp`, but ideally I'd like to do it without modifying that variable, or when `company-reftex` is not called, for example when using LSP.
https://redd.it/1b9u9si
@r_emacs
Consistent Technical Documents Using Emacs and Org Mode
https://youtu.be/0g9BcZvQbXU?si=OD5awJtaZWc2l9lo
https://redd.it/1b9lynf
@r_emacs
100% CPU Usage When Web Links in Org Mode
I noticed my computer was running hot and discovered that emacs was using 100% CPU usage on one core. I ran the profiler and it shows ~80% usage by redisplay_internal (C function) > jit-lock-function > jit-lock-fontify-now > jit-lock--run-functions > run-hook-wrapped. I then noticed this only occurred with org files that had links to web pages. For example, I opened an org file without links and CPU usage was low, I then added a link to a webpage and CPU usage went to 100%. In case it's relevant, I'm using doom with emacs 28.1.
Please let me know if you have any ideas or if there's any other info I should provide.
https://redd.it/1b96nk4
@r_emacs
help replicating my vim/tmux workflow
I want to learn emacs as a long-time neovim user. I love the way emacs is self documented as I find it so challenging to understand/fix things myself in neovim.
I work on a monorepo at my job - a variety of projects in different languages inside of a single git repo. I will open a tmux session in my terminal emulator and keep a window open for whatever number of the projects I'm working with on. Typically I will use an alias to open a project in a new window, open neovim, and open a vertical split with a shell for running the project.
The thing I like about this is it's super easy to switch between projects and they all keep whatever pane layout I have set up. I can also spawn new windows for any other work I need to do.
I'm not really getting how I can do this in emacs. I have set up dashboard.el and projectile.el and can open a project, but I have to then open another emacs frame if I want to open another project. I would much prefer to have a little tab bar or some shortcuts to switch between projects in a single frame.
Any guidance is appreciated!
https://redd.it/1b9c9ha
@r_emacs
Magit problems
So I installed Emacs 29.2 on my new laptop, downloaded my dotfiles and opened emacs so it can install all my setup. And lo and behold, magit's broken, despite being the exact same config as on my previous laptop, where I do not run into this issue.
Here's the problem. If I make a change, and run `magit-status` the unstaged changes don't show up in the buffer. And as you can see, there's several in the repo when I run `git status`. If I tap s, I get the option to choose a file to stage from a little pop-up. But normally the files would show in the "unstaged changes" and I would be able to inspect, stage all or one at a time, etc.
https://preview.redd.it/b8qzm0oeizmc1.png?width=2972&format=png&auto=webp&s=ab58d7d28089a9379e77381443cde32550489dd5
Anyone have any ideas? (my org init file in case it helps debug)
​
I love Emacs a lot, but I'm more and more contemplating just moving away because I waste so much time just getting things to work or fixing issues that randomly crop up. le sigh
https://redd.it/1b96wxn
@r_emacs
eshell - Directing command output to symbol
In eshell, I know that I can do things like:
listify *foo.bar \> #'my-var ; Store list of filenames in var
(first my-var)
Is there a way to skip the intermediate variable? What I really want is:
(first (listify *foo.bar) ;; Doesn't work because of mix of eshell commands and elisp.
Ideas? The docs are pretty thin on this.
https://redd.it/1b967ui
@r_emacs
Extracting Headlines By Tag for Thematic Analysis in Emacs Lisp
Greetings everyone,
I wanted to share a function that I've found incredibly useful while conducting qualitative data analysis of interviews. During this type of research, structuring my interview data and maintaining a clear overview is crucial. To assist with this, I've developed a function in Emacs Lisp that uses tags to extract specific headlines into a new buffer.
This function, *extract-headlines-by-tag*, prompts the user to enter a tag. The function then scans the entire buffer, and for each headline that contains the specified tag, it extracts not only the headline but also its content. These extracted parts are then transferred into a new buffer. I've made the new buffer pop up for immediate review after the extraction process.
Here's the piece of code:
(defun extract-headlines-by-tag (tag)
"Extract headlines and their content from current buffer by TAG."
(interactive "sEnter tag: ")
(save-excursion
(let ((result-buffer (generate-new-buffer (concat "/Extracted Headlines " tag "*"))))
(with-current-buffer result-buffer
(org-mode)
(insert "* Extracted Headlines by Tag: " tag " *\n\n"))
(org-element-map (org-element-parse-buffer) 'headline
(lambda (headline)
(when (member tag (org-element-property :tags headline))
(with-current-buffer result-buffer
(insert (org-element-interpret-data headline) "\n")))))
(pop-to-buffer result-buffer))))
This has greatly improved the way I manage and analyze my qualitative interview data. Sharing it here in case it's of use to anyone else in similar situations.
https://redd.it/1b90dwt
@r_emacs
path.
Command "marksman" is not present on the path.
Command "kotlin-language-server" is not present on the path.
Command "elp server" is not present on the path.
Command "credo-language-server --stdio=true" is not present on the path.
Command "cmake-language-server" is not present on the path.
Command "/home/vaeep/.emacs.d/.cache/lsp/clangd/clangd_15.0.6/bin/clangd --header-insertion-decorators=0" is present on the path.
Unable to install typescript via `npm' because it is not present
Command "rust-analyzer" is not present on the path.
Command "perlnavigator --stdio" is not present on the path.
Command "java -jar /home/vaeep/.emacs.d/.cache/lsp/magik-ls/magik-language-server-0.9.0.jar --debug" is not present on the path.
Command "nginx-language-server" is not present on the path.
Command "marksman" is not present on the path.
Command "kotlin-language-server" is not present on the path.
Command "elp server" is not present on the path.
Command "credo-language-server --stdio=true" is not present on the path.
Command "cmake-language-server" is not present on the path.
Command "/home/vaeep/.emacs.d/.cache/lsp/clangd/clangd_15.0.6/bin/clangd --header-insertion-decorators=0" is present on the path.
Unable to install typescript via `npm' because it is not present
Anyone knows how to solve? btw, I use asdf to manage my language versions. This could be a problem?
https://redd.it/1b8z4ub
@r_emacs
A Basic Demo of Local tts in emacs.
Demo , local realtime tts using piper in Emacs , this can have many uses since emacs is a text editor after all. Here is the relevent code and Piper Repo
https://redd.it/1b8upzj
@r_emacs
8x faster JSON parsing (can be useful for language servers)
I implemented a custom JSON parser for emacs. Instead of using a library which creates an intermediary JSON representation which is then converted to Lisp objects, my solution creates Lisps objects from the JSON stream without any intermediary steps.
Measured by \~1 MB of clang LSP messages, it works \~8x faster than the current emacs JSON parser. Maybe it can be helpful for people whose LSP works slowly, as an alternative solution to emacs-lsp-booster
(I didn't do any comparisons).
You can check out the faster-json-parsing
branch here: https://github.com/geza-herman/emacs/tree/faster-json-parsing. Is it based on master, but I think it can be easily applied to any recent version of Emacs (it's just one commit).
This JSON parser misses some error handling, like for example it doesn't check for utf-8 encoding errors. So please consider it as a proof of concept, not as a production quality thing. But I've been using it for a while, it works for me with clangd
perfectly.
https://redd.it/1b8qmv5
@r_emacs
Trying To Increase The Minimum Amount A Buffer Can Shrink To
I am trying and failing to find a way to increase the minimum amount a buffer can be shrunk down so only the modeline is showing and none of the text from the file is visible. For my use case, I am using a hydra to navigate around my buffers and every time a buffer is focused I run maximize-window, what I want to happen is the other open buffers stack on top of each other like in i3 can this be done?
https://redd.it/1b8kzcr
@r_emacs
How do I configure LSP mode with Auctex?
I am getting the following error when I am trying to start the lsp
server on top of Auctex
Unable to calculate the languageId for buffer ‘h.tex’. Take a look at ‘lsp-language-id-configuration’. The ‘major-mode’ is LaTeX-mode
Here is what I have tried so far in my init.el
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "texlab")
:activation-fn (lsp-activate-on "LaTeX-mode")
:server-id 'texlab))
But it's still not working. Any help is appreciated, thanks.
https://redd.it/1baagby
@r_emacs
color in vterm
hi, how can i add colors to my vterm? right now it is the plain background of my current theme with all white everything. for example, make directories blue, some other nice color or theme.
https://redd.it/1babi2v
@r_emacs
emacs 29.1 on macos hanging
I see this has been brought up in the past, but no definite solution. I've got a reliably failing scenario in a pretty vanilla system (emacs-mac from brew, GNU Emacs 29.1 (build 1, aarch64-apple-darwin22.5.0, Carbon Version
169 AppKit 2299.6) of 2023-08-08, current m2 mac, working through the emacs-bedrock configuration so there's not a lot loaded).
Essentially if I use the right click context menu, and move the pointer around said menu, I'll get the briefly spinning and then forever frozen beachball cursor. C-g does nothing, pkill -SIGUSR2 also did nothing helpful.
I don't need the context menu, so I've removed the code in init.el that enables context-menu-mode.
Anyone else still seeing these hangs, or have any ideas on a real solution?
https://redd.it/1ba3819
@r_emacs
Best way to move point around
I am a long time vim user. I started using emacs about four years ago mainly for notmuch email.
I tried evil for a while, but it had some quirks and incompatibilities with other packages, so I went back to the default key bindings.
I find the default key bindings to just not stick with me. I keep reverting to using the cursor keys or mouse. Do the majority of folks use the default key bindings? Or do you map them to something that suites you? Or do I just need to force myself to use the default keys?
In the various discussions I have never gotten a feel for just how wide spread evil is.
Thanks.
https://redd.it/1ba0o8y
@r_emacs
I love Emacs but I need to share C-x with it or find a prefix key equally lightweight on the digits
Emacs is a fantastic software that has become my swiss army knife as a pentester. The problem is that recently I've had a muscle issue, radiculopathy, and navigating around DWM with my current configuration is my personal hell. This is fixable with a reworked sxhkd configuration.
Questions regarding the issue:
Q1: Is there a prefix key on the left side of the keyboard that can feel as smooth as firing C-x without creating any real pressure between the thumb and index finger?
BLABLABLA: Define smooth, right? lmao... ig the same way you can glide on and off the defaults for save-buffer, or new-window-on-right.
Q2: Is there a way to get Emacs to use the same exact hotkey you're using globally?
BLABLABLA: This is obviously the magical, superfast route, so I don't expect a response to this question. Maybe though... a script, syntactical directive, something...
Answer either question at your leisure. I'm still hacking away at it myself and just wanted to delegate the task to anyone willing. C-x and M-x appear to be masterful in terms of flexibility.
https://redd.it/1b9vqxp
@r_emacs
Treesitter performance of json-ts-mode
Read on - this is not a rant but an exchange wheather I should subimt a bug report
Using GNU Emacs 30.0.50 (build 1, x86_64-w64-mingw32), pre-built treesitter libraries version v0.12.148 from https://github.com/emacs-tree-sitter/tree-sitter-langs/releases
When I open a prettified JSON with 17944 lines, 370 kB in size, opening takes
js-json-mode: 1 Second
json-ts-mode: 10 Seconds
Larger files also open, but become simply unwildly to use as eg. an undo seems to completely re-parse the file in json-ts-mode, which makes operating files in that mode really cumbersome.
So using json-ts-mode is an order of magnitude slower and I wonder if my settings are wrong, this is to be expected or if I should submit a bug report?
https://redd.it/1b9iqw2
@r_emacs
Cursor like built in AI codegen with emacs?
Hi all,
I've been trying out Cursor recently - it's a fork of VSCode with AI codegen baked in.
They do some interesting things like indexing your codebase via embeddings and then use RAG to help do contextual codegen. You can provide your own API keys as well.
This has been by far the best AI codegen experience, IMO. I was wondering if there are any good packages that replicate similar functionality in emacs.
https://redd.it/1b98sa4
@r_emacs
GitHub - federicotdn/key-quiz: Key Quiz game for GNU Emacs
https://github.com/federicotdn/key-quiz
https://redd.it/1b9clot
@r_emacs
256 colours, in emacs, in Windows terminal?
I swear I've looked at every google result imaginable but cannot get this to work.
I've set TERM = xterm-256color in Windows Terminal, I've set it in my emacs init.el but yet whenever I check getenv TERM it returns 'dumb' and doing a meta-x list-colors-display shows me 16 colours. I know the actual Windows Terminal can display 256 colours because I ran some Python to get it to display them and it worked as expected. Any idea how I can get this to work? Is it even possible? Sadly it's a work PC so I have no option but to use Windows otherwise I'd just use Linux and be done with it.
https://redd.it/1b92xd3
@r_emacs
Use 12-hour time for iCalendar display in mu4e
When I get an iCalendar (text/calendar
) MIME part, it shows up in a mu4e article buffer like this:
Summary: Pre-Planning Meeting
Location: Room 101
Time: <2024-03-07 13:00-14:00>
Organizer: wgates@microsoft.com
Attendance: Required
Method: REQUEST
Status: Not replied yet
How can I get the time to display in a 12-hour format, like "2024-03-07 1 pm-2 pm"? Including a UTC offset would be nice, too.
https://redd.it/1b8uzdp
@r_emacs
Dealing with completing-read-separator
when one of the candidates matches the value of crm-separator
Suppose I call completing-read-multiple
with the following list of candidates:
("1" "2,3" "4,5,6")
If the value of crm-separator
is [ \t]*,[ \t]*
, selecting the second candidate will result in the list ("2" "3")
, and not (as one might have expected) ("2, 3")
. This is not very surprising of course, and if you are building your own completion tables for use with completing-read-multiple
, the problem can be avoided by keeping the value of crm-separator
in mind. The problem is that sometimes the completion table is generated on the basis of input the user may have no control over.
For example, in mu4e
there's a function mu4e-view-save-attachments
which does what the name suggests: it lists all attachments in a given message for the user to choose (possibly more than one) and then saves the selected attachments in a specific directory. If you are dealing with a message with files whose names contain a comma, selecting one of those files will lead to trouble.
Now, I can just define a little function that will temporarily change the value of crm-separator
to handle these cases, e.g.:
(defun my/toggle-crm-separator ()
(interactive)
(let ((original-separator " \t,[ \t]"))
(if (string= crm-separator original-separator)
(let ((separator (completing-read "Select one of the following options" '(";" ",," "-"))))
(setq crm-separator (replace-regexp-in-string "," separator crm-separator)))
(setq crm-separator original-separator))))
Still, I wonder if there's a smarter solution out there. Off the cuff, I can imagine scanning the completion candidates to ensure none of them contain an instance of the value of crm-separator
and, if they do, at least alerting the user of the need to pick a different value for crm-separator
? But I don't know if there's a better way to handle this situation.
Thoughts?
https://redd.it/1b91eyj
@r_emacs
Trouble with installing LSP servers
So I've came from Neovim to Emacs about 2 weeks ago and I'm trying to setup LSP code completion but for some reason it can't install the servers to run. Trying with ts-ls server my lsp-log give me this error:
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Found the following clients for /home/vaeep/dev/kata/tests/js/test.ts: (server-id eslint, priority -1)
The following clients were selected based on priority: (server-id eslint, priority -1)
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Found the following clients for /home/vaeep/dev/kata/tests/js/test.ts: (server-id eslint, priority -1)
The following clients were selected based on priority: (server-id eslint, priority -1)
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Found the following clients for /home/vaeep/dev/kata/tests/js/test.ts: (server-id eslint, priority -1)
The following clients were selected based on priority: (server-id eslint, priority -1)
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Found the following clients for /home/vaeep/dev/kata/tests/js/test.ts: (server-id eslint, priority -1)
The following clients were selected based on priority: (server-id eslint, priority -1)
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Command "semgrep lsp" is not present on the path.
Command "deno lsp" is not present on the path.
Found the following clients for /home/vaeep/dev/kata/tests/js/test.ts: (server-id eslint, priority -1)
The following clients were selected based on priority: (server-id eslint, priority -1)
Command "rust-analyzer" is not present on the path.
Command "perlnavigator --stdio" is not present on the path.
Command "java -jar /home/vaeep/.emacs.d/.cache/lsp/magik-ls/magik-language-server-0.9.0.jar --debug" is not present on the path.
Command "nginx-language-server" is not present on the path.
Command "marksman" is not present on the path.
Command "kotlin-language-server" is not present on the path.
Command "elp server" is not present on the path.
Command "credo-language-server --stdio=true" is not present on the path.
Command "cmake-language-server" is not present on the path.
Command "/home/vaeep/.emacs.d/.cache/lsp/clangd/clangd_15.0.6/bin/clangd --header-insertion-decorators=0" is present on the path.
Unable to install typescript via `npm' because it is not present
Command "rust-analyzer" is not present on the path.
Command "perlnavigator --stdio" is not present on the path.
Command "java -jar /home/vaeep/.emacs.d/.cache/lsp/magik-ls/magik-language-server-0.9.0.jar --debug" is not present on the path.
Command "nginx-language-server" is not present on the path.
Command "marksman" is not present on the path.
Command "kotlin-language-server" is not present on the path.
Command "elp server" is not present on the path.
Command "credo-language-server --stdio=true" is not present on the path.
Command "cmake-language-server" is not present on the path.
Command "/home/vaeep/.emacs.d/.cache/lsp/clangd/clangd_15.0.6/bin/clangd --header-insertion-decorators=0" is present on the path.
Unable to install typescript via `npm' because it is not present
Command "rust-analyzer" is not present on the path.
Command "perlnavigator --stdio" is not present on the path.
Command "java -jar /home/vaeep/.emacs.d/.cache/lsp/magik-ls/magik-language-server-0.9.0.jar --debug" is not present on the path.
Command "nginx-language-server" is not present on the
How can I add this elisp link to the scratch buffer?
I have the following in my emacs configuration:
(setq initial-scratch-message
(concat " Welcome 😀 to 's 🏠 Emacs ☕\n =org-ql= searches\n \"[elisp:(org-ql-search (org-agenda-files) '(and (not (habit)) (not (done)) (tags \"work\")) :sort '(date) :title \"Today's work items\")💼 Today's Work] \n Recent files (<SPC o o> to open)\n"
(mapconcat (lambda (x) (format " + [elisp:(find-file \"%s\")%s]" x (url-file-nondirectory x))) recentf-list "\n")
"\n\n ELISP Evaluation area:\n#+beginsrc emacs-lisp\n(message \"Hello World\")\n(auto-package-update-now)\n#+endsrc\n"))
Everything is working fine, except for the org-ql link, somehow the single quote '
before the query '(and (not (habit)) (not (done)) (ta....
gets replaced with a '❛' and I get the following error when I try to open the link (unless I manually fix it, then it works):
Symbol's value as variable is void
found confusable character '❛' perhaps you meant '''
What can cause this, and how can I achieve what I want?
https://redd.it/1b8vvbq
@r_emacs
Buffer partitioning--is there a way to keep one set of buffers completely separate?
So my first instinct when I have some notes to take is to fire up notepad++, despite having used emacs for 20 years. I've never liked using emacs for plain text; it's always felt like a code editor only to me.
I'd kind of like to use it for more text things, but one thing that I'm not sure how to do is maybe fire up a frame that only has access to txt/org files and won't be cross-contaminated by all the code buffers I have open. Is there a good way to have a frame/window be dedicated to a type of file?
https://redd.it/1b856yr
@r_emacs
Evil mode help rebinding C-n and C-p in minibuffer mode
Hi all!
I have evil mode enabled in my minibuffer by setting the evil-want-minibuffer
variable to true. Is there a way to rebind C-n and C-p specifically in the
minibuffer? I tried remapping it using the following but it didn't work
(define-key minibuffer-local-map (kbd "C-p") 'previous-line)
C-n next-complete-history-element [2 times]
C-p previous-complete-history-element [4 times]
C-p evil-complete-previous [6 times]
C-n evil-complete-next [3 times]