reddit / emacs

Weekly Tips, Tricks, &c. Thread

AutoModerator · 2022-09-28 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.
com4 · 2022-09-29 00:27
In preparation for the inclusion of eglot into Emacs core I've switched away from lsp-mode. As a result I've also switched from flycheck and to flymake. One nice thing about flycheck is that it allowed for stacking checkers. When coding Python I liked to stack flake8 for styles and mypy for types (plus the LSP's since it's already there). Flymake allows for stacking checkers but it turns out eglot clobbers these checkers when "adding" the LSP's checker. To get stacked Flymake checkers with Eglot you can simply add them back after Eglot has done it's thing. For example, here is a simple setup for Python which includes Pyright's type checking and flake8 style checking ;; Use flake8 as the python style checker by default (setq python-flymake-command '("flake8" "-")) (use-package eglot :hook ((python-mode . eglot-ensure) (eglot-managed-mode . (lambda () ;; re-enable flymake checkers because eglot clobbers ;; them when starting (when (derived-mode-p 'python-mode) (add-hook 'flymake-diagnostic-functions 'python-flymake nil t))))) :custom ;; shutdown server after killing last managed buffer (eglot-autoshutdown t) :bind (("C-c l r" . eglot-rename)) :config (add-to-list 'eglot-server-programs `(python-mode "pyright-langserver" "-w" "--stdio"))) Now all that's left is mypy. Flymake originally used a ["Proc"](https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend) method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](http://github.com/com4/flymake-mypy). It can be enabled when using eglot like this: (use-package flymake-mypy :straight (flymake-mypy :type git :host github :repo "com4/flymake-mypy") :hook ((eglot-managed-mode . (lambda () (when (derived-mode-p 'python-mode) (flymake-mypy-enable)))))) After opening a Python buffer and executing `M-x flymake-running-backends` we are greeted with a list of stacked checkers: `Running backends: eglot-flymake-backend, flymake-mypy--run, python-flymake`.
Scroot · 2022-09-29 21:21
This is great, thanks
itistheblurstoftimes · 2022-09-29 23:42
It used to be that when I looked at a function or variable with C-h f (or v), the help buffer would have a link to see all the references to that function. I don't know exactly when this disappeared. I may have removed a package that added this, or maybe it was lost in an upgrade, or whatever. Does anyone know how I can get this feature back? It was incredibly useful for seeing how functions are used when they don't have much documentation.
MitchellMarquez42 · 2022-09-30 01:00
Package called Helpful. Might not be what you were using but it does that and a few other cool things.
itistheblurstoftimes · 2022-09-30 01:04
Thank you!
ares623 · 2022-09-30 07:49
What distro has Emacs 28 with native compilation available in its default repo?
h-m-b-tu · 2022-09-30 09:56
Arch: emacs-nativecomp
vjgoh · 2022-10-02 22:22
More clangd/lsp/eldoc questions that google seems to be bad at answering. 1. Is there a way to get eldoc to display hover info in a dedicated frame? Not a child frame or the minibuffer, but a frame on its own. (I tried setting 'Eldoc Echo Area Prefer Doc Buffer' but it did nothing; whether the buffer is in a new frame or inside the current frame in a different window, it still displayed in the minibuffer.) 2. Is there a way to display a complete class, including all inherited values? I'd love to see the full composition of a class, from base to leaf. Maybe that's more of a clangd thing?
thoomfish · 2022-10-03 03:27
How do I make GUI Emacs (28.1, macOS) treat ESC and C-[ as the same thing? I'm trying out `meow` for modal editing on an otherwise completely stock Emacs config, and ESC works for leaving insert mode, but C-[ just shows "ESC-" in the minibuffer as if I'm trying to use it as the Meta prefix. If I run `emacs -nw` in a terminal, both work. My .emacs contains nothing other than the `straight.el` bootstrap code and the default `meow` QWERTY setup. There are lots of Google results for people trying to get Emacs to treat ESC and C-[ differently, but none that I can find for the reverse. Edit: It turns out in GUI Emacs, `ESC` and `<escape>` are different concepts. The solution was: (meow-define-keys 'insert '("ESC" . meow-insert-exit)) Edit 2: This turns out to break all `M-` keybinds in insert mode for reasons that I don't fully understand, which is annoying enough that I swapped the exit keybinding to `C-g`. Now I just have to hope *that* doesn't break anything.
ifixcomputers4money · 2022-10-04 01:38
Stolen, shamelessly, from an older Reddit thread. Basically: I wanted to use the built-in completion framework for find file. Having pruned/weaned myself off of Helm and Orderless/Vertico/etc. The one thing I felt I missed from those days is the "up directory" shortcut. This was (usually) bound to `C-l`. However the only analog I could find is `C-Backspace` or `M-Backspace`, which had the frustrating limitation of not working on directories with word boundaries in it (`.` or `[space]` or other characters). After a bit of searching for the right terms, I [found this on Reddit][1]: ```elisp (defun my/up-directory (path) "Move up a directory in PATH without affecting the kill buffer. Taken, shamelessly, from: https://old.reddit.com/r/emacs/comments/re31i6/how_to_go_up_one_directory_when_using_findfile_cx/" (interactive "p") (if (string-match-p "/." (minibuffer-contents)) (let ((end (point))) (re-search-backward "/.") (forward-char) (delete-region (point) end)))) ``` While it's not a native 'up-directory' command, it does exactly what I want, so there's that. Looking at it, I am sometimes surprised at how many little functions I have floating around in my config. To the point that I should really try and solve my own problems the obvious way like the above code, and only fix it if there is a better solution. Anyway. I hope this helps someone. [1]: https://old.reddit.com/r/emacs/comments/re31i6/how_to_go_up_one_directory_when_using_findfile_cx/
kovrik · 2022-10-04 19:47
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".
oantolin · 2022-10-05 05:14
If you use vertico, you could just bind `vertico-directory-delete-char` to DEL or `vertico-directory-delete-word` to `C-<backspace>` in `vertico-map`. (The first command makes DEL delete one character except if that character would be `/`, in which case it deletes a whole path component.)
Sudo_Brew · 2022-10-05 16:45
I know this is explicitly not what you asked for, but in case anyone else reading this finds it useful, I found a lot of use in putting eldoc into a child frame with [eldoc-box](https://github.com/casouri/eldoc-box). Unfortunately I'm of no help with the actual questions here, sorry
vjgoh · 2022-10-11 19:19
Yeah, I've tried eldoc box but it never really puts the documentation where I want, which is why I want a completely separate frame. But it IS a nice little add-on for people who aren't me. :D