This channel is a feed for r/emacs. @r_channels @reddit2telegram
Weekly Tips, Tricks, &c. Thread
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.
https://redd.it/17vp0o1
@r_emacs
I have created an abomination
A few days ago I asked if there was a Vim port of Denote. Well, I went ahead and had ChatGPT help me make one.
Here it is: https://git.sr.ht/~ashton314/vim-denote
Why make this? So my Vim-using friends (what can I say—I'm a tolerant guy) can work with me on some shared Denote-formatted notes.
Is the package awful? Yes. Am I gonna fix it? No. I've written enough Vim script to last a long time. I'll go back to the nice land of Emacs Lisp now. (In spite of all its warts, it's still a Lisp and therefore beautiful.)
https://redd.it/17vm6hw
@r_emacs
Generic LSP server as a flymake/flycheck backend?
The context here is, I'm working in a company environment that is using https://trunk.io in its dev environment, which is kind of a meta-linter for many languages. It wraps a bunch of backend lint tools and combines their results, and enforces a company wide policy on all of them. They provide integrations for a few IDEs, but nothing specific to emacs yet. What they do provide is an LSP proxy to their tool. I have been looking if there is any support in flymake or flycheck to use a generic LSP server as the checker backend, and I haven't found anything. Does anyone know if this is possible? Or if there's an existing backend that's close enough that could be tweaked to do this? I've attempted to duplicate the trunk configuration using individual flymake backends, and the maintenance is just too much. It would be way easier to just make use of the tool directly.
https://redd.it/17vabem
@r_emacs
How are circular function references and forward function declarations handled in emacs lisp?
By forward function declarations I mean what is needed when a function defined later in the file is called from a preceding one.
By circular I mean file A requires a function in file B which requires a function in file A. Something along those lines
PS. Apologies for inquiring about this again. I am sure I enquired sometime in the past and forgotten the actual question and the response to it.
https://redd.it/17v7j5p
@r_emacs
goto-last-change doesn't work well
If I understand it right, goto-last-change
should go to the places where I made the last edits. But often, when I want to go back, it seems to have "forgotten" them, jumps to a very old edit, and then displays "No further change info" in the minibuffer.
I just had the problem again. I made sure the edits are very far away, many lines in the same org-buffer. Neither goto-last-change-reverse
nor goto-last-change
does find them. But when I use undo-redo
, all my "forgotten" edits are found and subsequently undone. How can that be?
Do you use a different function for going back to the last edits? Or am I using goto-last-change
in a wrong way? The variable glc-default-span
is set to 8, and I am using Org mode version 9.6.9 and Emacs 29.1. Thank you for any advice!
Edit: I also use undo-fu-session
, could it be that this interferes with goto-last-change
?
https://redd.it/17v30cs
@r_emacs
A consistent way to map C-{lowercase}
and C-{uppercase}
?
Hi. I'm getting really frustrated by how unpredictable `C-` mappings are when it's bound to both uppercase and lowercase character. What I've tried:
(global-set-key (kbd "C-q") 'cmd)
(global-set-key (kbd "C-Q" | "C-S-q" | "C-S-Q" | "C-\S-q" | "C-\S-Q" | ...) 'cmd-2)
and swapping the lines.
I never manage to get the intended behaviour – it keeps translating the uppercase to lowercase or vice-versa. And sometimes it doesn't – there seems to be no pattern.
Could someone help me out?
https://redd.it/17v0p3k
@r_emacs
suggestions for synthwave theme?
I use doom emacs, and while I love the default purple / blue / orange - I fancy a change and wonder what synthwave themes are out there?
Do recommend your favourites!
So far I've seen:
​
1. the port of the VScode Synthwave '84 theme \- though:
1. not noob friendly as it's not in doom-themes
2. seems to not have the extra-cool glow effect (no idea how to achieve that on emacs)
2. the doom-themes
port of laserwave
Any others I should consider?
https://redd.it/17ulblm
@r_emacs
Installing 2 Different builds of Emacs Version (29) (Attempt to fix fonts in Wayland)
I came across an issue using Emacs when switching to a wayland compositor (hyprland).
The fonts don't look right as you can see at the screenshot below, but zooming in makes it better.
My current emacs build is using LUCID no PGTK.
I'm thinking of building another Emacs build with PGTK support that runs natively on Wayland without Xwayland. However i'd like to install them both.
As i use Lucid version on XMonad most the time, but still when i switching to wayland i could still have a better font.
u
https://preview.redd.it/nnoue1xr470c1.png?width=685&format=png&auto=webp&s=544a2c57604eeff12de176ca12b83528e752d68e
u
https://redd.it/17unwu6
@r_emacs
Any way to make a variable save its old value?
I'm wondering if there's any way to make a variable automatically save its old value, so that I can, e.g., write a minor mode that will automatically restore the old values of variables when it's deactivated (without having to declare a bunch of -old-value
variables).
https://redd.it/17ujodz
@r_emacs
Combining use-package and general(use-package elfeed)
(leader-key "w" elfeed)
Is it possible to combine the two in a simple way? I tried using :general
keyword in use-package ensuring that it loads after general, but it still does not work...
https://redd.it/17i9fxt
@r_emacs
A literate Org document on building Emacs from source - conditionally for RedHat or Debian
https://gitlab.com/spudlyo/orgdemo2
https://redd.it/17i0v03
@r_emacs
Ellama moved to llm library and now supports proprietary LLMs as well as open source
ellama is a tool for interacting with LLMs from Emacs. It now uses llm library as a backend and supports various providers.
https://redd.it/17hvcsi
@r_emacs
ispell breaks my org-mode heading folding/unfolding
As the title says, when i run M-x ispell when it reaches a word under an org mode heading it won't unfold the heading, so my cursor is just on the actual heading and not the incorrect word and then when i quit ispell i can't unfold that heading with tab. I have to kill and yank the heading to get it working again. I pasted some of my init file below incase that helps.
* I've tried this with flyspell disabled and get the same results, so i think it is an ispell issue.
* I have also tried this with emacs -q and running M-x ispell and get the same issue.
* I'm using emacs+ on mac
Thanks!
Org settings:
* Org mode
** General tweaks
#+begin_src emacs-lisp
;; indent with tabs for better readability
(add-hook 'org-mode-hook #'org-indent-mode)
;; (setq org-indent-indentation-per-level 4)
;; them source blocks as they would in their native mode.
(setq org-src-fontify-natively t
org-src-tab-acts-natively t
org-confirm-babel-evaluate nil)
#+end_src
** Packages
*** org-bullets
#+BEGIN_SRC emacs-lisp
;; Org bullets makes things look pretty
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
#+END_SRC
ispell and flyspell settings:
** spell checking
*** ispell
#+begin_src emacs-lisp
(use-package ispell
:ensure t)
(setq ispell-program-name "aspell")
(setq ispell-extra-args '("--sug-mode=ultra"))
(setq ispell-dictionary "english")
#+end_src
*** flyspell
#+begin_src emacs-lisp
(use-package flyspell
:ensure t
:config
(setq ispell-program-name "aspell") ; Use Aspell as the spell checker
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode))
;; recommended to speed up flycheck
(setq flyspell-issue-message-flag nil)
;; easy spell check
(global-set-key (kbd "<f8>") 'ispell-word)
(global-set-key (kbd "C-S-<f8>") 'flyspell-mode)
(global-set-key (kbd "C-M-<f8>") 'flyspell-buffer)
(global-set-key (kbd "C-<f8>") 'flyspell-check-previous-highlighted-word)
(defun flyspell-check-next-highlighted-word ()
"Custom function to spell check next highlighted word"
(interactive)
(flyspell-goto-next-error)
(ispell-word)
)
(global-set-key (kbd "M-<f8>") 'flyspell-check-next-highlighted-word)
​
https://redd.it/17hnc1q
@r_emacs
Changing the value of a theme variable
I'm using the adwaita-dark theme but the mode-line is too wide for my liking. In the theme code there's a variable (mode-line-padding 10) which I assume sets the width of the mode line. Is there a way for me to reset this value in my init file, either before or after loading the theme code, to make it narrower? I'm using the code below to load it.
(use-package adwaita-dark-theme
:ensure t
:config
(load-theme 'adwaita-dark t))
​
https://redd.it/17his6w
@r_emacs
How to preview buffer with HTML in eww/browser?
I know I can use M-x browse-url-of-buffer
to create a temp file and render it on my default browser. But how could I render it with eww
?
I tried the function suggested here, but I get the error message that says:
> eww-display-html: Buffer nil doesn’t exist
The use case is the following:
1. Export org as HTML (to a temp buffer);
2. Render the HTML to a browser, my default browser or eww.
Any suggestions?
https://redd.it/17h4h4k
@r_emacs
Better code autocompletion in Emacs?
Hello, emacs fellas.
I'm trying to set up emacs for webdev and I cannot get good completions for html and css. I have installed lsp-mode
and html-ls
along with css-ls
, but completions are still rather poor compared to VSCode.
Is there a way to get better autocomplete?
https://redd.it/17vng2l
@r_emacs
My code to send raw keystrokes to ansi-term doesn't work with Emacs 29.1
I have this code:
(defun send-raw-key-fun (str)
(lexical-let ((str str))
(lambda ()
(interactive)
(term-send-raw-string (read-kbd-macro str)))))
(define-key term-raw-map (kbd "C-c c") (send-raw-key-fun "C-c"))
and it doesn't work anymore with ansi-term. I'm not able to end the process inside.
Got error:
(wrong-type-argument stringp 3)
Does anyone know what to do to make this code work again?
https://redd.it/17vd26l
@r_emacs
Does anyone have a function they use to quickly copy org as markdown vice-versa?
I don't want to export the entire file as markdown, I want to copy a region which assumes org syntax with the syntax converted to markdown syntax. Also, I want to be able to paste something that was copied using markdown syntax as org syntax. Does anyone currently have anything for this?
https://redd.it/17um2fk
@r_emacs
Emacs natively on Wayland (PGTK) is slower than on Xwayland (Lucid) Also fonts are not looking good on both (but good on X).
I have rebuilt Emacs 29 with PGTK in order to get Emacs running natively and to fix the fonts, and i already have another emacs 29 build (Lucid) installed with i use On X.
I was surprised to see Emacs on wayland was running slower than its counterpart on Xwayland. Also the fonts issue was not fixed.
While zooming in makes the fonts look better. On X i don't have this issue.
Below is screenshots of fonts on Wayland - Xwayland and X
​
On wayland \(PGTK\)
​
Xwayland \(Lucid\)
​
Xorg \(Lucid\)
https://redd.it/17v43rw
@r_emacs
OrgNote - mobile app inspired by org-roam and org-roam-ui (early beta)
https://redd.it/17v427x
@r_emacs
Frustrating python lsp experience
I'm losing my mind over emacs as a python IDE. It seems that no matter which LSP concept I attempt, the experience is suboptimal. At best it is riddled with odd issues, and at worst almost bordering unusable.
I work as a python developer, and I work on quite large code bases. The LSP experience is essential for me given the complexity, but I'm at the point of giving up, even though I've been an emacs user for the better part of a decade.
I use doom emacs, by the way, but I'm quite happy to try anything to solve this. I have considered to build an emacs config from scratch again to see if I can narrow down the experience, but right now I have not invested the time. But again, considering how frustrated and desparate I am, everything is on the table.
Let me describe what I need and what I've tried.
#### My requirements
I need my lsp to understand my environment in order to load in a custom PYTHONPATH
variable. This I handle with a .envrc file and the emacs module envrc
. This has worked without any problems so far.
For the actual LSP, I use python-lsp-server
but I am not at all religious about it.
I run mypy
on my codebase, and I'd like to use ruff
for checking/formating, but I've used the other tools (pycodestyle
/black
) for now.
### lsp-mode
The lsp-mode is the one that is closest to being good, had it not been for the abysmal behavior over time. It seems that some memory leaking happens, and over time it becomes sluggish, sometimes blocking emacs for multiple seconds.
### eglot
Eglot seems a lot faster, but has functional problems. I've often had to restart eglot when opening new python modules.
I've tried to use eglot for months now, accepting the quirks to gain the speed, but the restart behavior is annoying, and I often get weird errors such as error in process filter: Wrong type argument: plistp, []
repeatedly until I restart eglot again. No luck debugging that error so far either.
I'm also not super excited about the .dir-locals.el
approach to customization, but should the other issues resolve, I'm willing to figure that one out.
### lsp-bridge
I was quite excited to hear about a third option that was super fast. However, I've not manage to get it to work with the envrc
package, so I've parked that one.
So, I turn to you, kind strangers on the internet. Do you have a well-functioning python LSP setup in emacs? Have you experienced some of the issues that I have described and did you manage to solve it?
Do you perhaps have a described approach to building a great python setup with emacs? Please help me!
https://redd.it/17uyy08
@r_emacs
How do improve code diagnostics in eglot?
Hi everyone! I'm currently using doom emacs with eglot
. And I'm quite happy of how lightweight it is. However, I'm only able to see the diagnostics message when hovering the cursor over some error.
I wonder if there is any similar package or eglot configuration to replicate what Error Lens does in vscode? Thank you in advance.
My config looks as follows, I'd kindly appreciate any suggestion that could help me to improve my eglot experience:
(use-package! eglot
:defer t
:init
(setq eglot-autoshutdown t)
:config
(setq eglot-ignored-server-capabilities '(:hoverProvider :documentLinkProvider :inlayHintProvider :documentOnTypeFormattingProvider))
(add-to-list 'eglot-server-programs '(rust-mode "rust-analyzer"))
(add-to-list 'eglot-server-programs '(scala-mode "metals"))
(add-hook 'eglot-managed-mode-hook (lambda () (flymake-mode -1)))
:hook
((rjsx-mode rust-mode typescript-mode js2-mode scala-mode) . eglot-ensure))
​
https://redd.it/17up2hc
@r_emacs
Spurious "unknown type" compiler warnings in Emacs 29.1?
According to the documentation of the CL library, it is allowed to have code like
(cl-check-type '(a b) proper-list)
where the undefined type symbol proper-list
will be automatically interpreted as
and indeed it does work. However, after upgrading from Emacs 27.1 to 29.1, I am suddenly getting a compiler warning
Warning: Unknown type: proper-list
for such lines, unless I either rewrite it more verbosely as
(cl-check-type '(a b) (satisfies proper-list-p))
or provide an explicit type definition
(cl-deftype proper-list () '(satisfies proper-list-p))
Is anyone aware, if this is intended behavior?
https://redd.it/17ujlo0
@r_emacs
Using custom packages with Elpaca
I am trying to replace straight with Elpaca but I have some troubles with loading some of my local packages that are not from Melpa.
The use-case is to load laas a package for latex snippets. I use the following code
​
(use-package aas
:elpaca nil
:load-path (lambda () (expand-file-name "custom/" user-emacs-directory))
)
(use-package laas
:elpaca nil
:load-path (lambda () (expand-file-name "custom/" user-emacs-directory))
:config
(aas-set-snippets 'laas-mode
;; set condition!
:cond #'texmathp ; expand only while in math
"On" "O(n)"
"O1" "O(1)"
;; bind to functions!
"Sum" (lambda () (interactive)
(yas-expand-snippet "\\sum_{$1}^{$2} $0"))
"Span" (lambda () (interactive)
(yas-expand-snippet "\\Span($1)$0"))
"lr(" (lambda () (interactive)
(yas-expand-snippet "\\left($0\\right)"))
"lr[" (lambda () (interactive)
(yas-expand-snippet "\\left[$0\\right]"))
"lr{" (lambda () (interactive)
(yas-expand-snippet "\\left\\{$0\\right\\}"))
)
(laas-mode)
)
​
Both files \`aas.el\` and \`laas.el\` are in my \`(lambda () (expand-file-name "custom/" user-emacs-directory))\` repository and with straight these lines of code worked well but when I switched to Elpaca, laas was not loaded anymore. I tried to add :after tex, do not change anything. I tried to add a hook for latex mode and it also do not change, the laas package is not even loaded.
Can someone help me with this please?
​
https://redd.it/17ia9ee
@r_emacs
Any guide how to change font colors?
I'm facing a really tough issue with colors getting all messed up after switching to wayland. Is there any simple guide to understand how to change fonts/faces colors in emacs?
https://redd.it/17i2y3f
@r_emacs
Hardware: BlueTooth Keyboard for Emacs (DooM)?
https://redd.it/17hvjcw
@r_emacs
Possible to use fd
or some other faster search tool than find
with consult
I have been using `find` with `consult-find`, but it's a bit slow. I'm wondering if it would be possible to speed it up using some other tool such as `fd`. I noticed that the consult README talks about `consult-fd` but I cannot locate that function anywhere in my version which is I think the latest `0.35`. Can anyone help with this?
Also, similarly, consult-grep is a bit slow. Wondering if one can swap in `ag` for example?
https://redd.it/17hqz2o
@r_emacs
Search engine
I want to use set google as the search engine for emacs but can't figure out the process
https://redd.it/17hl0dl
@r_emacs
My Dired Symlink Hack
https://youtube.com/watch?v=59XPGvJMggY&si=hOjzfmFB2Es9WNOI
https://redd.it/17hgd7l
@r_emacs
How to create a personal wiki in emacs?
I know this question has been asked before and I know about org-roam, I am just not sure if org-roam is the right solution for me. Right now, I use one big org file to take notes which I export to pdf. This works nicely, but it would be nice to also have access to the concepts in the larger org file at a granular level (ie. bite-sized notes which reference one another and are organized based on their subject matter). I would also like to tag information that is not in org format, if possible. I was thinking that org-roam & org-transclusion could be used to make main subject files, while org-roam could be used to make a link to an embedded pdf that comes from the concept I am referencing, when I don't need to explicitly review the material in whatever notes I am taking. Has anybody done anything like this? Any tips are appreciated. Thanks.
https://redd.it/17h80vl
@r_emacs