reddit / emacs
Weekly Tips, Tricks, &c. Thread
AutoModerator · 2022-12-14 08:15
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.](https://www.reddit.com/r/emacs/search?q=Weekly+tips&restrict_sr=on&sort=new&t=all)
Don't feel constrained in regards to what you post, just keep your post vaguely, generally on the topic of emacs.
vatai · 2022-12-14 14:57
Ok! Let's try... I'm starting emacs daemon using systemd, and it gives some "authentication message not specified" (or similar) message, (sorry I can't check now)... the systemd job seems to be alive and well... but I can't connect to it with `emacsclient`... I do a `systemctl restart --user emacs.service` and it all works just fine. It's a bit annoying...
harinath · 2022-12-14 16:56
Me too. The log has something like:
Invalid MIT-MAGIC-COOKIE-1 key
[deleted] · 2022-12-14 18:38
[deleted]
holgerschurig · 2022-12-14 21:46
This magic cookie is X11 related. Something in your Emacs config triggers loading / accessing X11, but Emacs can't, because he hasn't the "magic cookie", the key to open X11's access control.
The_Great_Danish · 2022-12-14 23:09
To play back a macro, you press C-x e. To play the same macro back, you just press e. How does that work? I want to do something similar for a custom command I made. I wrote a function that duplicates a line, and set it to fire on C-c d. I want to be able to press just d to duplicate the line after an initial C-c d.
kickingvegas1 · 2022-12-14 23:36
Emacs support for conversion to different calendars (e.g. Lunar (Chinese), Hebrew, Islamic, Astronomical) is undefeated. For example, figuring out when the Lunar New Year in 2023 is `calendar-chinese-goto-date`, keybinding: `g C <ret> 40 1 1`.
<https://www.gnu.org/software/emacs/manual/html_node/emacs/Other-Calendars.html>
tryptych · 2022-12-14 23:39
You're looking for `repeat-mode`: [https://www.masteringemacs.org/article/mastering-key-bindings-emacs](https://www.masteringemacs.org/article/mastering-key-bindings-emacs)
There's a few packages around that make it simpler to define bindings, etc (and use-package supports it now too)
eleven_cupfuls · 2022-12-14 23:42
In general, by temporarily activating a keymap. As of Emacs 28 the easiest way to do this is to use `repeat-mode` and its `repeat-map` property, which goes basically like this:
;; Define the command
(defun my/duplicate-line (...)
(interactive)
...)
;; Create a keymap and bind any commands you want to be repeatable within it
(defvar my/line-command-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "d") #'my/duplicate-line)
;; Other bindings...
map))
;; For each command that you want to trigger that map, set its `repeat-map'
;; property
(put 'my/duplicate-line 'repeat-map my/line-command-repeat-map)
;; Etc...
There are a few packages floating around to simplify this; it's a pretty straightforward macro to write. And `use-package` also supports it in its `:bind` handler.
harinath · 2022-12-15 02:44
Exactly.
It appears that some part of the login session startup, including the emacs daemon startup, happens before the $XAUTHORITY environment variable (and possibly $PATH) is set. On restarting the daemon, it picks up the correct environment, and is able to work just fine.
Since the workaround is simple, I haven't bothered fixing this. Probably requires a dependency on X11 startup in the emacs.service file.
_viz_ · 2022-12-15 03:48
IMO it is not worth your time to fight systemd in this case. Starting the daemon in your xinitrc file is much more easier and headache-free.
holyfudge · 2022-12-15 10:08
How do you guys start a new project with emacs? Is there something like snippets for filestructure/dependecies?
I really like hos simple it is to setup something with intellij/pycharm.
Extension_Try_6870 · 2022-12-15 18:15
If you want to do it from emacs you can try https://melpa.org/#/prefab for example.
HM0880 · 2022-12-15 18:41
A more general way is to use the `repeat` function. The default binding is `C-x z`, but I bind to `M-o`.
So for u/The_Great_Danish, what you would do is type `C-c d` then type `M-o` as many times as you need.
AP145 · 2022-12-17 04:13
When I implement `(global-hl-line-mode 1)` in my init.el file I notice that there is this very thick distracting line that forms on the border of the highlighted line that I would like to get rid of. Is there some command that will help me do that? Also, is there a way I can change a color scheme so that it would make the top of Emacs, above the menu bar, dark themed as well?
eleven_cupfuls · 2022-12-17 18:49
`hl-line-mode` uses the `hl-line-face` to draw the highlight, so take a look at the spec for that face.
[deleted] · 2022-12-17 18:51
[deleted]
whyimihere2019 · 2022-12-18 17:47
Im using the new tsx-ts-mode, is there a way to make emacs insert closing html tags automatically?
The_Great_Danish · 2022-12-19 06:17
Thank you!