reddit / emacs
Weekly Tips, Tricks, &c. Thread
AutoModerator · 2022-11-30 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.
Wonnk13 · 2022-11-30 14:52
https://github.com/manateelazycat/lsp-bridge popped up recently in a HN discussion thread. I have a relatively unremarkable config with lsp and company to give me completions. Is there any benefit to adding this? I don't see any performance degradation with my current setup, so I'm a little nervous to add one more variable...
lispers-anonymous · 2022-12-01 03:11
Lsp-bridge is an alternative to lsp-mode, not something to enhance it.
That said, it couldn't hurt to try out. There is also eglot.
itistheblurstoftimes · 2022-12-01 04:55
Does anyone else use [oauth2ms](https://github.com/harishkrupo/oauth2ms) for fetching their MS mail via mbsync?
After an upgrade I am getting an error and something must have changed in one of the dependencies. I don't know python, don't have emacs set up to debug python, and trying to figure this out is a very painful process. Hoping someone else's email broke who can help.
hairlesscaveman · 2022-12-01 10:49
I have LSP configured to suggest type specs in my language of choice. It is very useful, however it's position is rather annoying. I would prefer to have the overlay _above_ the function, but currently the overlay starts at the end of the function signature.
Is there a setting I can change to move this above the function?
Wonnk13 · 2022-12-01 12:10
I don't know the answer to this, but I'm interested in responses. I imagine the config will be specific to each lsp server?
[deleted] · 2022-12-01 21:59
[deleted]
[deleted] · 2022-12-02 01:01
[removed]
Dank-memes-here · 2022-12-02 11:39
In the last two years I adopted both emacs and a tiling window manager (i3), which improved my productivity massively. Is there anything like this to adopt in the future? I'm not talking about zettelkasten or anything like that, just stuff that lets me interact with my pc more efficiently
itistheblurstoftimes · 2022-12-03 00:53
If this happens to anyone else just delete the cached credentials which, I learned after too many hours and learning too much python, is stored in `~/.local/share/oauth2ms`.
drewbarbs · 2022-12-03 11:50
For me, tmux is a similar game changer for terminal workflows
cat-head · 2022-12-03 23:08
[Meta] can we have "help me optimize my init file" type of questions?
condor2000 · 2022-12-04 09:45
There is a talk about it at EmacsConf
https://emacsconf.org/2022/talks/lspbridge/
slinchisl · 2022-12-04 11:54
I would sheepishly argue in favour of XMonad over i3, since the interaction with Emacs is really good [[1]](https://tony-zorman.com/posts/phd-workflow/2022-05-01-my-phd-workflow.html), [[2]](https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html), [[3]](https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html) (conflict of interest: I wrote most of that interaction).
Wonnk13 · 2022-12-04 15:40
I Just saw that! I'll have to give it a watch. I haven't noticed much lag with the "vanilla" `lsp` package along with `lsp-ui` and company mode. I don't necessary want to break something that isn't broken, but it'll be interesting to see how much traction this package gets.
chandergovind · 2022-12-06 04:52
You can use [https://github.com/alols/xcape](https://github.com/alols/xcape) to overload your modifier keys. I have been using this for my tiling window manager operations (dwm in my case) to do things like switching to last tag, cycling through windows etc with single keypresses. I just realized that it may be even more effective to bind single keys for emacs use - such as \`C-x\` or \`C-c\`. Have to try this out now.
Another thing that I swear by is to invert the number-row in your keyboard (using xmodmap). So, now you insert "!" when you press <1> and to insert "1", you have to <Shift+1>. My reasoning is that if you are programmer, you need the symbols more often than the numbers. You don't even lose anything if you happen to have a numpad. Your mileage may vary - but I think the symbols win out if you do any bit of Lisp programming and/or use evil. (You do have to modify your twm to work with this, though.)
fernseedd · 2022-12-06 15:20
Wow, I think you've convinced me to switch to Xmonad. I'm a Ratpoison user, so I had been leaning more towards StumpWM. Thanks for the links!
alecStewart1 · 2022-12-06 23:27
I like [project-rootfile](https://github.com/buzztaiki/project-rootfile.el).
One thing about it though is when you're using TRAMP, be it that you're actually SSH-ing into a different machine or using it to `sudo/doas` into a file on your machine, it struggles and mentions a lot of `No applicable method for (project-root . "the directory you're in")`. What would need to be modified to fix this?
The other thing is project files that are denoted with just a file extension. So I have this bit
(defvar project:root-file-globs
'("*.nimble"
"*.asd")
"A list of globs for project files that mark the root of the project")
(defun project:project-root-p (dir &optional stop-dir)
"Return non-nil if DIR is a project root.
If STOP-DIR is specified, return nil if DIR is not a subdirectory of it."
(and (or (null stop-dir)
(file-in-directory-p dir stop-dir))
(or
(seq-some (lambda (f) (file-exists-p (expand-file-name f dir)))
project:root-files)
(seq-some (lambda (f)
(if-let ((glob-match (file-expand-wildcards f)))
;; We only need to check if the first glob matched file actually exists,
;; especially in the case of if a project just have one project file.
(file-exists-p (expand-file-name (car glob-match) dir))
""))
project:root-file-globs))))
And I just wanted to verify if this makes sense to those of you who's Emacs-fu is far better than mine.
juicecelery · 2022-12-07 16:03
Try a keyboard like the ErgoDox EZ where you can have keyboard layers. This massively improved my interaction with my PC!
According to the task at hand, I can quickly tune my keyboard layout and just get stuff done faster :)
terminal_cope · 2022-12-10 00:01
I like having some integration between i3 and Emacs windows. I use the same bindings to move windows and move focus for both.
I have the keys bound in i3 to a script that, if it's not an Emacs window, does the move, but if it is, send it to the Emacs in focus (via emacsclient) which does `windmove` internally, or if it hits an edge, calls *back* to i3-msg to tell it to do the move after all. Some people go further with this but window movement is the only thing I really find useful.
I also run multiple Emacs daemons, loosely bound to i3 workspaces. I have one key bound to open a window on this workspace's Emacs, or another to launch for the first Emacs found (which is my 'primary' instance).
fuzzbomb23 · 2022-12-10 00:11
Emacs 29 has an new setting which does something similar.
(defcustom project-vc-extra-root-markers nil
"List of additional markers to signal project roots.
A marker is either a base file name or a glob pattern for such.
alecStewart1 · 2022-12-10 05:17
Damn, how did I miss that? Thanks!
terminal_cope · 2022-12-10 16:55
Hey elispers - Am I wrong or does whatever elisp checker you get with flycheck enabled give a false negative. (I was just poking around to understand what that checker is, but it wasn't immediately obvious to me)
It gives me an error `value returned from (json-parse-string line) is unused` here where I added the comment.
(condition-case result
(json-parse-string line) ;; value returned *is* used - silly checker
(:success
(do-thing-with-the-parsed-json result)
((json-parse-error json-readtable-error)
(handle-json-parse-error result))))
Surely this is legit usage and the checker is wrong? Is there an inline way to silence the checker?
WorldsEndless · 2022-12-12 16:11
A great functionality for calculating some schedule events is `org-evaluate-time-range` (`C-c C-y`). When I need to propose an event of a particular length, I use this to get my length right between two dates.
Stefan-Kangas · 2022-12-13 23:42
Wow, thanks! I didn't know about this. Looks useful.
your_sweetpea · 2022-12-16 11:39
I'm not a decision-maker here but I don't see why that wouldn't be allowed.
That said, have you profiled your init with [esup](https://github.com/jschaf/esup)? The result won't be exactly the same as a normal startup, but it gives you a good overview of areas to focus on (although some things are just slow and there's not much you can do other than eliminate them or switch to an alternative).
cat-head · 2022-12-16 13:21
I'm down to 0.7 seconds, so the profiler isn't that much help anymore.
your_sweetpea · 2022-12-16 15:11
Hm, I've personally managed to squeeze my emacs down to 0.12 seconds as measured by esup and 0.26-0.32 as measured by `emacs-init-time`, but I have an uncommonly thin config, only 250-ish lines total and I use a number of less-than-idiomatic hacks to increase start speed (at the cost of maintainability, perhaps, but with only 250 lines of config it doesn't really matter too much).
If you want to share your .emacs.d, I'm definitely down to take a look, though.
Mine is [here](https://github.com/lambdadog/.emacs.d) if you're interested, but I admit it's not terribly comprehensible and it's fairly frequently unclear *why* I've done something (and whether it's a personal preference or a performance hack).
luiggi_oasis · 2022-12-21 15:48
I did ask that the other day and got great advice, no pushback. I think actually people like looking at your init.el and sharing their tips.
timmymayes · 2022-12-21 22:56
Gonna give this a read through.
holgerschurig · 2022-12-25 15:24
> Is there anything like this to adopt in the future?
I don't really understand this, but if i3 (or sway) wouldn't have used a custom protocol but instead DBUS, then Emacs could directly control it.
As it is now, you'll need to run "swaymsg" from Emacs to control it.
holgerschurig · 2022-12-25 15:25
For me, text mode Emacs is like running with clutches.
I want my graphical emacs, be it for PDF, the odd graphics, nicer fonts, better handling of some special keys.
holgerschurig · 2022-12-25 15:27
You could file this as bug perhaps?
terminal_cope · 2022-12-26 02:15
Yeah, probably should.
donio · 2022-12-28 17:08
EXWM is the next step on the WM path. The benefit compared to normal tiling WMs is that X11 window management is folded into Emacs buffer management.
[deleted] · 2022-12-29 15:43
[deleted]
thetemp_ · 2022-12-31 05:05
Guix. I have only scratched the surface of it so far, but it seems like you can have the same system configuration on all your computers (laptop, desktop, etc.), and it will set up your whole system. So you never go through setting up a new Linux install again.
It reminds me of how you can have an Emacs config that adjusts, depending on which system it's running on, installs your packages and so on.
It's also integrated really well with Emacs.