reddit / emacs
Weekly Tips, Tricks, &c. Thread
AutoModerator · 2022-10-05 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.
Jack-o-tall-tales · 2022-10-05 08:42
Wrote this, so I could have a single unified tagging command, whatever I'm doing with org:
(defun my/org-roam-add-current-tags (&optional arg)
"Add tags to current headline or node, depending on location.
If not in an org-roam node, behave exactly like
`org-set-tags-command'.
Otherwise (that is, in an org-roam node), if in a headline, set
tags for that headline. If not in a headline, or with a prefix
ARG, set tags for whole node."
(interactive "P")
(cond
;; Not in an org-roam node, revert to standard behaviour
((not (org-roam-file-p))
(org-set-tags-command arg))
;; roam node and at a heading (and no arg) -- set heading tags
((and (not arg) (org-get-heading))
(org-set-tags-command))
;; roam node, not in a headline (or with prefix arg) -- set
;; roam-node tags.
(t (call-interactively #'org-roam-tag-add))))
FrostyX_cz · 2022-10-05 13:43
If you are maintaining any package in Fedora, you probably often run `rpmdev-bumpspec /path/to/your/foo.spec` command. It annoyed me to always switch to a terminal because of that, so I wrote a very simple Emacs commands for it.
(defun frostyx/rpmdev-bumpspec ()
(interactive)
(shell-command
(string-join (list "rpmdev-bumpspec" buffer-file-name) " ")))
(defun frostyx/rpmdev-bumpspec-new-version (version)
(interactive "sNew version: ")
(shell-command
(string-join
(list "rpmdev-bumpspec"
buffer-file-name
"--new"
version)
" ")))
slinchisl · 2022-10-06 07:33
I finally got around to writing a small README for my Emacs config, highlighting some homegrown parts that I really like. I reckon most of these things are pretty standard, but maybe some people here still find it useful:
https://gitlab.com/slotThe/dotfiles/-/tree/master/emacs/.config/emacs
jokem59 · 2022-10-06 18:51
Does anyone rebind the exit chord \`C-x C-c\` to something else? I've exited emacs on accident when I my finger falls between the `x` and `c` keys and I was curious what others rebind the exist chord to?
whatacold · 2022-10-07 01:48
You can define a dumb lambda command and then bind the chord to it.
nv-elisp · 2022-10-08 20:31
`ignore` is a command. No need for a lambda.
tapesales · 2022-10-08 22:13
I just found out that you can enable imenu inside pdf-tools buffers really easily. I've been pressing 'o' for years to get a pdf outline, which works fine, but I like imenu more, since I've got it hooked into vertico and can do completing-read to get to the heading I want. I've also made it so that imenu completing-read opens up in a 'buffer indexed' type of vertico buffer. The effect is that imenu opens off to the side, like the original pdftools index. I'll post the snippets here:
\+ vertico customisation for imenu:
`(vertico-multiform-mode)`
`;; Configure the display per command.`
`;; Use a buffer with indices for imenu`
`(setq vertico-multiform-commands`
`'((consult-imenu buffer indexed)))`
\+ enable imenu in pdftools buffers:
`(add-hook 'pdf-tools-enabled-hook #'pdf-outline-imenu-enable)`
Hope it makes someone's experience better. Thank you to the package creators and maintainers for this functionality.
eleven_cupfuls · 2022-10-09 17:23
FYI in the future, if a mode does not provide imenu support (or you want to customize it), it's pretty straightforward. It's basically just a list of regexes. See `imenu-generic-expression`: https://www.gnu.org/software/emacs/manual/html_node/elisp/Imenu.html
kovrik · 2022-10-09 19:15
Could anyone please help me with the following Evil-mode issue?
Somehow it stopped copying/pasting to/from system clipboard (MacOS) via \`+\` register. Pretty sure it used to work. But now when I copy something into system clipboard then do "+p in Emacs it says "+ register is empty"
scbagley · 2022-10-10 12:57
You can keep the binding, while avoiding unwanted exits: `(setq confirm-kill-emacs 'y-or-n-p)`
itistheblurstoftimes · 2022-10-11 01:27
Did firefox suddenly stop overriding C-n and opening a new window?
Because C-n suddenly works.
Is this a dream?
Did I configure something that fixed it and forgot that I did it? Like in some kind of late night haze of trying to avoid real work? Was it an update?
itistheblurstoftimes · 2022-10-11 01:28
IT IS AMAZING HOW MUCH BETTER THIS HAS MADE MY LIFE.
demasoni_fish · 2022-10-11 14:27
Does anyone know how to add a column of numbers having commas in a org-mode table? \`vsum\` does not work when the numbers have commas.
jokem59 · 2022-10-11 17:43
This is great, thank you!