reddit / emacs

Weekly Tips, Tricks, &c. Thread

AutoModerator · 2022-02-23 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.
doctordesh · 2022-02-23 08:45
When I run `godoc-at-point` I get this message output: godoc: zsh:1: unmatched " How do I go about debugging this? I have no idea where to start...
colemaker360 · 2022-02-23 13:15
I was never really happy with commenting/uncommenting functionality in Emacs. I was using `comment-dwim` (dwim := do what I mean) but it never truly did what I meant. Honestly, the VSCode way of commenting/uncommenting with ⌘-/ from anywhere on the line or selected region was what I really was after. I recently found [Evil Nerd Commenter](https://github.com/redguardtoo/evil-nerd-commenter) and am really pleased with it. Don't let the name fool you - Evil mode not required at all. I added this shortcut in my init.el and have been really happy with it: `(global-set-key (kbd "s-/") 'evilnc-comment-or-uncomment-lines)`
shitterwithaclitter · 2022-02-23 17:49
Is there a way to get marginalia annotations and embark actions to show up for straight commands (like straight-use-package and friends)?
crawsphi · 2022-02-23 18:15
At a glance it doesn't look like straight supplies a completion category for its lists, so patching that would be a necessary first step.
jalihal · 2022-02-23 18:20
I have a question about elfeed, but it might stem from a misunderstanding of how RSS feeds work. I subscribe to the feeds of academic journals, and maybe once or twice a day, I refresh my feed. I go through my feed and tag various articles so I can categorize them. However, often a journal feed refreshes the same objects that I have already viewed, maybe just updating the time stamp. This causes the items to lose the tag I have assigned them, and instead the `unread` tag gets added to them again. How do I prevent this from happening? Is there any way for elfeed to disambiguate the content of a feed so it doesn't overwrite a 'read' feed object?
shitterwithaclitter · 2022-02-23 18:25
I've been trying to use eshell as my main shell/terminal and I wrote a few useful functions that let me use eshell with emacsclient but not end up with like 15 eshell buffers that were only used for 1 command. First, define the following function: (defun my/eshell-scratchpad () "This should be called from the command line to launch emacs with a scratchpad This sets the 'eshell-buffer' parameter so the buffer can be killed when the frame closes" (eshell t) ;; don't ever delete the first eshell buffer (unless (string= eshell-buffer-name (buffer-name)) (set-frame-parameter nil 'eshell-buffer (current-buffer)))) This adds a frame-parameter set to the eshell buffer name that we can use to kill the buffer when emacs closes. I deliberately made this not set the parameter for the base eshell buffer, but you can change that by removing the call to `unless`. To automatically delete the eshell buffer when you close the frame, add the following to your init.el: (defun my/close-eshell-scratchpad (&optional _frame) "Closes the eshell scratchpad. To be run in 'delete-frame-functions'" (let ((eshell-buffer (frame-parameter nil 'eshell-buffer))) (when eshell-buffer (kill-buffer eshell-buffer)))) (add-hook 'delete-frame-functions 'my/close-eshell-scratchpad) Now, to directly launch an eshell instance, start emacs with the command `emacsclient -c -a "" -e "(my/eshell-scratchpad)"`. When you close the window, the buffer will be deleted. I also wrote a bonus function: (defun eshell/saveterm () "Run this in an eshell scratchpad to stop the the buffer from being killed when the window exits" (set-frame-parameter nil 'eshell-buffer nil)) Now, you can run the command `saveterm` in eshell if you don't want the buffer to be killed.
meain · 2022-02-23 18:31
You can match on prompt string IIRC
tryptych · 2022-02-23 19:44
Is `comment-line` closer to what you're after? (Bound to `C-x C-;` by default). It looks similar; toggles commenting on the current line, and takes a numeric argument.
sauntcartas · 2022-02-23 21:54
You can do `M-x toggle-debug-on-error` and then rerun your failing command. It will give you a stack trace from the point of failure.
sauntcartas · 2022-02-23 22:03
I've been ramping up my EMMS usage lately. I often listen to quite lengthy MP3s and want to jump around by minutes or hours, but the built-in `emms-seek` command only lets you specify a number of seconds. So I finally buckled down and wrote this: (defun my-emms-seek (Δt) (interactive "sTime to seek: ") (pcase Δt ((rx bos (? (let negative "-")) (?? (let hours (+ digit)) ":") (? (let minutes (+ digit)) ":") (let seconds (+ digit)) eos) (emms-seek (* (if negative -1 +1) (+ (string-to-number seconds) (* (if minutes (string-to-number minutes) 0) 60) (* (if hours (string-to-number hours) 0) 3600))))) (_ (error "Don't understand seek time “%s”" Δt)))) Now I can seek around a playing MP3 file by providing a more natural time specification like `"5:00"` (ahead five minutes) or `"-1:00:00"` (backwards one hour).
AffectionateAd8985 · 2022-02-24 01:56
Press "?" to toggle dired cheatsheet: ```elisp (use-package dired :bind (:map dired-mode-map ([remap dired-summary] . which-key-show-major-mode)) ``` Optionally, if you want less noise: ```elisp (add-to-list 'which-key-replacement-alist '((nil . "digit-argument") . t)) ```
colemaker360 · 2022-02-24 02:20
It's close. but it moves the point to the next line. I just want the cursor to remain where it was. Ideally, I'd like the selected region to remain selected as well.
tryptych · 2022-02-24 02:47
Fair enough, thanks.
oantolin · 2022-02-24 06:16
There is some [sample code](https://github.com/oantolin/embark/wiki/Additional-Actions#package-actions-using-straightel) on the embark wiki to configure: 1. Marginalia to provide a `straight` completion category (for any command whose prompt contains "recipe" or "package", and 2. Embark to provide actions for straight commands. So, with that, you'd just be missing an annotator.
Hastrack · 2022-02-24 12:42
I always felt the emacs input was laggy, but recently I find a solution, increasing the auto repeat rate made a big difference. In X11: >xset r rate 170 40 You can play around to see which values works better for you.
bravosierrasierra · 2022-02-24 20:19
My frequently used function to sum all day expenses in diary: ``` (defun sum-numbers-in-region (start end) "Sum all numbers in region and place result into kill ring." (interactive "r") (let* ((sum (cl-reduce #'+ (split-string (buffer-substring start end)) :key #'string-to-number))) (message "Sum for all numbers in region is %s. Result stored in clipboard." sum) (kill-new (format "%s" sum))))) ```
spekvojbek · 2022-02-25 12:45
Is it possible to change the layout/appearance of the breadcrumb headerline of LSP enabled by `lsp-headerline-breadcrumb-enable`? I'd like it to look like the modeline from [spaceline](https://github.com/TheBB/spaceline)
lstrang · 2022-02-26 11:27
Nice tip. Thanks!
aladine123 · 2022-02-26 23:36
Hi everyone, I am using emacs with doom-emacs configuration. Recently I found that all the chars beyond 80 chars for each line will be highlight red. How could I disable it. I guess it is `display-fill-column-indicator-mode` but it is not.
_viz_ · 2022-02-27 02:30
Ask Emacs. Move the point to the red coloured text, type C-u C-x =, scroll down to the text properties section, see the face used, describe that face using M-x describe-face. Now, the Help buffer should show the file name which defined the face and that will help you figure out how to turn it off.
aladine123 · 2022-02-27 03:22
Thanks a lot. After checking the face, I found it is due to whitespace mode. Disable this mode fixes the issue. ``` Face: whitespace-line (sample) (customize this face) Documentation: Face used to visualize "long" lines. ```
StrangeAstronomer · 2022-03-06 00:19
Try posting to the author at [https://github.com/skeeto/elfeed/issues](https://github.com/skeeto/elfeed/issues) ???