This channel is a feed for r/emacs. @r_channels @reddit2telegram
What is the proper way to set East Asia font preference?
I'd like to use the fonts in the following order for East Asia text.
1. AR PL UKai HK
2. BabelStone Han
3. UnGungseo
4. Noto Sans CJK KR
The lines that follow are the settings I've gathered to enlarge the text for easier reading.
1 (dolist (charset '(han symbol cjk-misc bopomofo))
2 (set-fontset-font t charset (font-spec :family "AR PL UKai HK" :size 28 :registry "big5")))
3
4 (set-fontset-font t '(#x2ff0 . #x2fff) (font-spec :family "AR PL UKai HK" :size 28))
5
6 (set-fontset-font t '(#x4dc0 . #x4dff) (font-spec :family "BabelStone Han" :size 28))
7
8 (set-fontset-font t #x21fea (font-spec :family "BabelStone Han" :size 28))
9
10 (dolist (x '( #x377f #x456c
11 #x53d3 #x53d5 #x5926 #x5b52 #x5f1c #x5387
12 #x6056 #x6abf #x6e70 #x6598 #x659a #x6752 #x67bc
13 #x7683 #x7a41 #x7c36 #x7e85
14 #x887a #x8c38 #x8a9d #x8a9f
15 #x9aea #x9af0 #x9f04 #x9f05
16 #xfe47 #xfe48))
17 (set-fontset-font t x (font-spec :family "Noto Sans CJK KR" :size 28)))
18
19 (dolist (x '(#x7232 #x654e #x7d76)) (set-fontset-font t x (font-spec :family "UnGungseo" :size 28)))
20
21 (dolist (x '(#x37a2
22 #x41c2 #x4b6b
23 #x5928
24 #x7680 #x8c59
25 #x2002c #x20447 #x27141 #x22992 #x22994
26 #x23a95 #x268fb #x27bab
27 #x294a8))
28 (set-fontset-font t x (font-spec :family "BabelStone Han" :size 28)))
Is there a better way to do that?
https://redd.it/17zse9v
@r_emacs
Eglot JSON RPC Connection Error 32603 "Internal Error"
I've been wanting to get Eglot working so that I may use its LSP for my classes and in the future. Right now I'm trying to get it working for Python and I have pyright installed with pip (as well as node as the GitHub repo stated I'd need that installed).
As the title says, when Eglot is trying to connect to the server, I get a jsonrpc error:
[client-reply] (id:0) ERROR Mon Nov 20 09:19:00 2023:
(:jsonrpc "2.0" :id 0 :error)
(:code -32603 :message "Internal error"))
Transparency for Doom Emacs 29.1 on Windows?
Just installed doom emacs 29.1 on Windows and transparency isn't working like it does for my install on Linux
(add-to-list 'default-frame-alist '(alpha-background . 95))
org-roam: Automatically log modified nodes in daily note
I found myself wanting to automatically keep a log of every org-roam entry I work on. After struggling with the capture system for a while, I managed to make something work.
(setf (alist-get "u" org-roam-dailies-capture-templates nil nil #'equal)
'("updated" plain nil
:target (file+head+olp "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n" ("Updated"))
:unnarrowed t :prepend t))
(defmacro +save-current-buffer (&rest body)
"Save current buffer; execute BODY; restore original buffer.
I have found that this macro works under some circumstances in
which ‘save-current-buffer’ does not."
(declare (indent 0))
`(let ((original-buffer (current-buffer)))
(unwind-protect (progn ,@body)
(when (buffer-name original-buffer)
(switch-to-buffer original-buffer)))))
(defmacro +temp-buffer-string (&rest body)
"Eval BODY in a temporary buffer and extract contents to a string."
(declare (indent 0))
`(with-temp-buffer
,@body
(buffer-string)))
(defun +org-element-contents (element)
"Extract contents of ELEMENT from current buffer."
(buffer-substring (org-element-property :contents-begin element)
(org-element-property :contents-end element)))
(defun +org-roam-updated-on-save ()
"Log current Org-roam buffer as modified."
(when (org-roam-buffer-p)
(let* ((original-buffer (current-buffer))
(id (org-id-get (point-min)))
(title (org-get-title))
(link-text (format "%s\n" (+temp-buffer-string
(org-insert-link nil id title)))))
(save-excursion ;; in case we are currently editing the daily note
(+save-current-buffer
(org-roam-dailies-goto-today "u")
(unless (eq original-buffer (current-buffer))
(let ((elt (org-element-context)))
(if (not (eq 'plain-list (org-element-type elt)))
(insert "\n- " link-text)
(org-down-element)
(unless (cl-loop
for elt = (org-element-context)
while (eq 'item (org-element-type elt))
;; don't log the file if it's already present
if (string-equal link-text (+org-element-contents elt)) return t
do (org-forward-element))
(insert "- " link-text))))))))))
(add-hook 'after-save-hook #'+org-roam-updated-on-save)
I originally tried to do this using *just* capture templates (i.e., just an interpolated Lisp expression, no wrapper code), but I'm not sure that that's possible due to the uniqueness check.
One thing I'm not happy about is having to use my weird homespun `+save-current-buffer` macro, but the original `save-current-buffer` macro doesn't switch back for some reason.
I am kind of? happy about having gotten some experience with the `loop` macro. I'm still not sure I like it, but I understand better why it exists in a language that doesn't have other, more structure looping facilities.
https://redd.it/17zm3qq
@r_emacs
A not-so-simple function and keybinding for querying the user during keyboard macros
Hey, I was working on this one off and on for a few days after briefly trying out skeleton-mode, yasnippet, and some other stuff, and not really being too happy with them. I find that I have a lot of repetitive editing tasks where I need to do something to a small block of code a lot, but in the process change some names or values in a way that's just a little bit different each time. Normally this is where people would start to reach for yasnippet and auto-yasnippet, which is fine if that works for them, but personally that's just a bit more heavyweight and powerful than what I normally need. What I wanted was just a way to enhance a regular Emacs keyboard macro to support that sort of thing, so I wrote this. If it helps you too, wonderful!
To use, just press C-x Q (that's a capital Q, not a lowercase q) during keyboard macro recording, and press your normal enter/return/minibuffer-exit when you're done. I went through a lot of trouble figuring out how to make the minibuffer exit also exit the sub-macro recording!
;; Keyboard macro enhancement. If you call this, instead of
;; kbd-macro-query, it will prompt the user for a value. This value
;; will then be inserted into the buffer. Every time you call the
;; macro, you can provide a different value.
;;
;; Alternatively, you can call this with a prefix argument. If you do
;; this, you will be prompted for a symbol name. Instead of the value
;; being inserted into the buffer, it will be saved in the symbol
;; variable. You can then manipulate it or do whatever you want with
;; that symbol as part of the keyboard macro. Just, when you do this,
;; make sure you don't use minibuffer history at all when defining the
;; macro, or you can get some unexpected behavior if you save your
;; macro for later use and try it a few hours later!
(defun config:macro-query (symbol)
(interactive
(list (when current-prefix-arg
(intern (read-from-minibuffer "symbol: ")))))
(cl-flet ((internal-exit ()
(interactive)
(exit-recursive-edit)))
(let ((making-macro defining-kbd-macro) ;; Save value.
(temp-map (make-sparse-keymap)))
;; Temporarily bind what is normally C-M-c (exit-recursive-edit)
;; to RET, so RET will work in the spawned minibuffer.
(set-keymap-parent temp-map minibuffer-local-map)
(substitute-key-definition 'exit-minibuffer #'internal-exit temp-map)
(let ((exit-fn (set-transient-map temp-map (-const t))))
(cl-flet ((also-quit-minibuffer ()
;; When this is called (advice after
;; recursive-edit), this-command should be
;; whatever was just used to exit the recursive
;; edit / minibuffer. Usually RET. Push that onto
;; the unread commands, and it will immediately
;; get picked up and executed. We also want to use
;; this moment to turn off the transient map.
(funcall exit-fn)
(when making-macro
(setq unread-command-events
(nconc (listify-key-sequence (this-command-keys))
unread-command-events)))))
(advice-add 'recursive-edit :after #'also-quit-minibuffer)
(unwind-protect
(let ((input (minibuffer-with-setup-hook
(lambda ()
(kbd-macro-query t))
(read-from-minibuffer "Value: "))))
(if symbol
(set symbol input)
(insert input)))
;; Ensure that the advice and minibuffer map goes back to
;; normal.
(advice-remove 'recursive-edit
C mode indentation weird
My only tab-related init.el
config is:
(setq-default indent-tabs-mode nil) ;; indentation can't insert tabs
(setq-default tab-width 4) ;; make tab-width 4 (spaces)
c-ts-mode
I have that the indentation only does and works with 2 spaces (I need to indent-region
whole file otherwise to fix it). How can I make this back to 4?Logseq equivalent for Emacs?
I've always been curious about Emacs but never made the plunge. I usually prefer vim/markdown vs org-mode/emacs. I've been using Logseq for some time but find the interface too sluggish. I found "ekg" emacs plugin but it's missing a few features to replace Logseq. I would like for all my notes to be combined into a single graph where they can be directly edited/manipulated without having to open up another buffer. Any other plugins aside from ekg that would give me a Logseq\-like experience? (no org-mode, no note titles) Thanks!
https://redd.it/17z6tju
@r_emacs
Project grep search with folded results, navigable file preview, search term and results window retention?
I'm looking for a way to preview the results of a grep search within files as well as fold the output when there are multiple matches in the same file.helm-projectile-ag
is my current grepping tool but doesn't seem to offer such a facility, unless I haven't read the docs well enough.
My issues are:
1. It can present a lot of hits in the same file it but lists each one separately. A good option would be to fold the output when there are multiple matches, then I can use the Tab keep to expand the fold and scan through the previews and even edit them right away.
2. The search panel is modal. It doesn't create a result buffer which you can save and then return to later to continue to select files to edit. Once you lose focus it is gone. It doesn't even seem to retain the search term so you can use it later.
3. It would be nice to have a window that shows the actual CLI command passed to the search utility. I see them once in a while but it would be good to show them up front or make them easily accessible.
Do any of the project grep tools or helm-projectile-ag
itself offer such features?
https://redd.it/17yw2kg
@r_emacs
c-ts-mode issue
When using cs-ts-mode, it incorrectly forces me to use paranthesis. For example:
if (whatever == -1)
{}
with the if statement, even if there is just one statement with a semi-colon after the if
. Also, as I'm typing, it weirdly indents my functions as I type them.C mode indentation weird
My only tab-related init.el
config is:
(setq-default indent-tabs-mode nil) ;; indentation can't insert tabs
(setq-default tab-width 4) ;; make tab-width 4 (spaces)
c-ts-mode
I have that the indentation only does and works with 2 spaces (I need to indent-region
whole file otherwise to fix it). How can I make this back to 4?Dashboard directory
Hello, I have immensely nested directories and very long filenames, some take up 3 lines when full screen.
Is there a way to shorten them or have just the name of the bookmark/file show up in the dashboard?
Sorry if noob question but I am a noob.
https://redd.it/17ydvzb
@r_emacs
Emacs: ediff basics
https://www.youtube.com/watch?v=pSvsAutseO0
https://redd.it/17yc6x6
@r_emacs
Virtual keyboard for emacs?
Im looking for a package or code snippets implementing a virtual keyboard in an emacs buffer, similar to what calc does but allowing full keyboard input (e.g. meta, super, letters, return ...). Is something like this allready in existance or does it have to be writen based on the calc code?
https://redd.it/17yaoma
@r_emacs
emacs org for brainstorming is not optimal
as mind map user I like to jot idea with parent, children, sibling hierarchy.
I am not satisfied with the present method of creating the three above as need to do a lot of adjustments ex option+ enter to create a new sibiling then ,Shift+<, or Shift+> to adapt the sibiling as a parent or sub. As I am in a creative process would like a faster way to achieve this.
For long list of sibilings I resolved writing in plain text the list and then shift+V and jjjj to select the list and then i launch toggle-heading, but this does not work if I add myself spaces in the plain text.
Please do you know a fast way to open a parent/children/sibiling node, I see a shortcut could be a solution, but do not know if is a good idea because should combine more commands
https://redd.it/17y4tsn
@r_emacs
Eoops: an object-oriented programming system for Emacs-Lisp: ACM SIGPLAN Lisp Pointers: Vol V, No 3
https://dl.acm.org/doi/10.1145/147135.147248
https://redd.it/17xuf0z
@r_emacs
neo emacs for beginners
[Neo emacs](https://github.com/sincebyte/neo-emacs) is a configuration for GNU Emacs which is based on doom emacs and focuses on the java web application coding environment.
Here is a detailed tutorial to teach you how to install doom emacs for beginners.
And here have many common configurations for beginners too.

Neo emacs has the following features:
* Code completion: Lsp-java supports maven and gradle project.
* Http client: Rest-client is a tool to manually explore and test HTTP REST webservices just like Postman.
* SQL client: Ejc-sql turns Emacs into a simple SQL client which supports various databases.
* Redis client: Eredis Non-blocking Redis client with focus on performance and robustness.
* Terminal emulator: Emacs-libvterm (vterm) is fully-fledged terminal emulator inside GNU Emacs based on libvterm.
* Knowledge management system: Org-roam borrows principles from the Zettelkasten method, providing a solution for non-hierarchical note-taking.
* [doomorgstyle](http://1.117.167.195/doc/doomorgstyle.html): An org html style template similar to doom doc.
Here I follow the rules, Try to keep the configuration of doom and enhance it. As a veteran, you may not use neo emacs directly. But the configuration here may also be useful to you!
Thanks for the support!
https://redd.it/17zpp0o
@r_emacs
Is the lack of multithreading support in emacs a dealbreaker for you?
View Poll
https://redd.it/17zoe3d
@r_emacs
Request for help fixing a font display issue with Emacs 29.1, X11
Screenshot: https://0x0.st/Hwru.jpg
In this Screenshot you see the frames of two Emacs processes. The left frame has been
started by emacs -q
, while the right frame has been started by emacs -Q
. So no
personal configuration (besides .Xresources
) is used. The version is Emacs 29.1.,
X11, Linux.
The left frame shows the font I'd like to use, and used since many years with Emacs
already. But the left frame also shows a "distorted" display of example characters.
The important character is …
. It is clearly visible in this screenshot, that Emacs
changes the font (glyph?) to display this character if the character needs to be
rendered in bold
. (similar things happen to other characters or itallic
)
Each frame has 3 windows. The top window shows an org buffer with various
characters.
The second from top window is the output of what-cursor-position
, of the normal
rendered character.
The bottom window shows the output of what-cursor-position
with a bold
character
where Emacs changed the font to display this character. (This lines are much wider
and taller, even though they contain the same number of monospaced letters.)
Emacs did not had this behavior of changing fonts to display certain characters in
versions v28.x and older (at least I never noticed it). I did not change OS installed
packages, fonts, setting and stuff, so I'm pretty sure it's an Emacs v28.x to v29.1
related change.
What can I do to make Emacs behave like in older versions, i.e. not changing fonts to
display those characters?
I tried various things (i.e. disabling HarfBuzz), but I am clueless what I need to
configure.
I know that the problematic setting is a *font:
line in my .Xresources
file. But
finding a suitable font was some time consuming frustrating process, because I didn't
like other fonts for various (mostly readability or size) reasons.
TL;DR: Question: how can I make Emacs v29.1 to not change fonts to display certain
characters?
https://redd.it/17zl4uq
@r_emacs
#'also-quit-minibuffer)
(funcall exit-fn)))))))
(global-set-key (kbd "C-x Q") 'config:macro-query)
https://redd.it/17zdgxw
@r_emacs
Defalias: a quick guide to making an alias in Emacs
https://youtube.com/watch?v=ufVldIrUOBg&si=ZT4WIT3IIjtZr5_0
https://redd.it/17zdhtt
@r_emacs
How to disable corfu only when lsp-bride-mode
is active?
Hi all!
This is mostly the question. I decided to give to lsp-bridge
a chance, but I am having this issue with Corfu.
https://preview.redd.it/vh8ku4xru31c1.png?width=629&format=png&auto=webp&s=3a69667f9c63b6948e0b91ad2ea8254b27ff3524
I installed Corfu using this PR in doom https://github.com/doomemacs/doomemacs/pull/7002
I would like to use lsp-bridge
when there is an LSP server available, but Corfu otherwise (minibuffer, plain text, etc.). Moreover, I tried this, but it didn't work:
(add-hook! 'lsp-bridge-mode-hook (lambda () (corfu-mode -1)))
Thanks for your assistance!
https://redd.it/17y692d
@r_emacs
Using Dired with only one hand (for browsing dired and files while relaxing) Super cool.
I am 100 % a keyboard only user, but sometimes i want to relax and browse dired only with one hand. But the standart behaviour of dired , when clicking on files or directories, is really ass. Thus i wrote some code to gain this functionality:
Left-Mouse-Click: The same as Pressing Enter
Right-Mouse-Click: close current buffer and go to last visible buffer
​
thus you can left click on entry, then go back with right click which is super fast and handy. Try it out !!!
(I am using evil, but you can easily bind the keys with :(define-key dired-mode-map .... )
code:
​(defun my/dired-jump (event)
(interactive "e")
(mouse-drag-region event)
(dired-find-file))
​(defun my/dired-jump-close ()
(interactive)
(kill-current-buffer))
​(evil-global-set-key 'normal (kbd "<mouse-3>") 'my/dired-jump-close)
​(evil-define-key '(normal visual motion emacs) dired-mode-map
(kbd "<down-mouse-1>") 'my/dired-jump)
EDIT: CHECK OUT THIS DEMO
https://imgur.com/a/G6K8JKO
​
https://redd.it/17z4kfo
@r_emacs
Making Emacs without terminal emulator a little more usable
https://magnus.therning.org/2023-11-19-making-emacs-without-terminal-emulator-a-little-more-usable.html
https://redd.it/17yshfc
@r_emacs
Advice from elisp hackers on improvemenets to tuedachu/ytdl?
Hey hey.
I use the heck out of tuedachu/ytdl. One thing I would like to improve about it is that when you queue a download with ytdl-download it appears to be a synchronous call and it freezes emacs until youtube-dl/yt-dlp is able to start the actual download.
I've yet to dive into the code to see what synchronous function is being called -- I'm very aware of the "single-threaded" nature of Emacs -- but I use other libraries that are likely shelling and they do not hang like this and so I would like to see if there's a way to I can bring whatever technique they are using over to a PR against tuedachu/ytdl.
Appreciate any advice from the crew here.
https://redd.it/17yalql
@r_emacs
C mode indentation weird
My only tab-related init.el
config is:
(setq-default indent-tabs-mode nil) ;; indentation can't insert tabs
(setq-default tab-width 4) ;; make tab-width 4 (spaces)
c-ts-mode
I have that the indentation only does and works with 2 spaces (I need to indent-region
whole file otherwise to fix it). How can I make this back to 4?I'm bumping treesit-auto
to v1.0
Aside from new language sources that the community can contribute at any time, this package feels more or less feature complete now.
v1.0.0 on GitHub
For those who don't know, treesit-auto
enables automatic detection, installation, and usage of tree-sitter grammars and modes in Emacs 29+. Vanilla Emacs exposes some variables and functions that facilitate this behavior, but without treesit-auto
it's up to you to check when tree-sitter is available and configure how Emacs behaves when it is (or isn't). This package takes that work away from you and is designed to fit what the vast majority of users would expect from automatic use of tree-sitter in Emacs.
This started out as just my own configuration to treesit-language-source-alist
, major-mode-remap-alist
, and auto-mode-alist
, but now has a lot of features that didn't exist just under a year ago when I first announced it.
1. Automatic detection and installation for built-in tree-sitter modes, such as rust-ts-mode
, yaml-ts-mode
, toml-ts-mode
, typescript-ts-mode
, and go-ts-mode
. You can get this behavior through the treesit-auto-add-to-auto-mode-alist
function (the name is too long...I know)
2. Less buggy behavior overall, such as ensuring we switch to the tree-sitter mode after installing it
3. Detecting and installing grammars required by the current mode, such as TypeScript and TSX requiring each other
This package isn't perfect. It's honestly still a bit of a hack, and many parts of the code are too clever for my own liking. It does its job, though, and I've been a happy, daily user of it for the last 9 months or so. Of course, a big thank you to all who have supported the project and contributed to it along the way!
https://redd.it/17ydxhr
@r_emacs
Enter key not working as expected on a new PC
Hi everyone. So im new to emacs and im currently using doom emacs on my laptop.
Everything is working fine, but today i decided to install it on my desktop. Im using all the settings from my laptop, but for some reason when i press enter on a link for example, emacs just goes down a line similiar to me pressing the down arrow/j key. This happens on all the links.
Any idea what the issue could be? This doesnt happen on my laptop
Edit: Just to clarify, clicking on the link with my mouse works normally.
Edit 2: Okay so apparently i needed to just do a doom sync since no profile was loaded i think. It said "generating profile" and now it works :) Noob misstake, but ill let this post still be here if anyone runs into the same problem in the future
https://redd.it/17yabho
@r_emacs
project-tasks: Efficient task management for your projects by using org-babel.
I would like to share with you a new Emacs package called project-tasks that I had been working on. With project-tasks, you can effortlessly manage tasks within your project using the power of org-babel.
You can take a look here https://github.com/TxGVNN/project-tasks
I developed and use it a long time, and it helps me a lot of to manage tasks I need to run on a project.
Example: tasks.org
#+name: docker-compose up
#+begin_src compile :name "docker-compose-up" :results none
docker-compose up -d
#+end_src
tasks.org
on repository.Iterating through a data structure doing interactive edits on each element
I have a number of edits I need to do to yaml files. I'd like to drive emacs in the following way: mapcar
over a list calling a function that opens a file, searches for a match, switches to interactive mode so I can adjust point, inserts some pre-formatted data specific to the match, allows me to edit the insertion to fix the inevitable typos that exist and, when I'm ready, saves the file and moves to the next element. I'm automating the file and buffer navigation as well as the content insertion but doing precise placement and editing by hand. Sadly, I did this once previously years ago but I don't remember how.
Relevant rant: this stupidity's only necessary because yaml's flexibility for too many ways to do the same thing so reading the yaml in, adjusting the data structures and writing it back out make pull requests horrific as minute semantic changes can have massive syntactic ones.
https://redd.it/17xumv4
@r_emacs
why is SPC-c c for compiling and SPC-c C for recompiling? DOOM EMACS
i'm pretty sure i'm overthinking this but why does doom emacs have
SPC-c c for compiling
and SPC-c C for recompiling
i thought it should've been other way round as i generally put the command for compiling and then just keep recompiling repeatedly and i believe doing SPC-c c is faster than pressing SPC-c C
​
when so you either have four keys to press by doing SPC-c c <CR> to recompile
or you have to press four keys by doing SPC-c <shift>c assuming you press shift for C
what i prefer doing is using SPC-c c for recompiling only three keys to press
and SPC-c <shift>c for compiling normally
​
it's just a little thing annoying me whenever i go from one config of doom emacs to another
every person i've seen doesn't reconfigure this. but they do seem to be bothered by this they do realize how annoying it is but don't want to go through the hassle to remap that
​
what do you guys think am i too paranoid about this is my OCD kicking in or do you feel the same ?
https://redd.it/17xn0e9
@r_emacs