reddit / emacs

Weekly Tips, Tricks, &c. Thread

AutoModerator · 2022-02-09 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.
[deleted] · 2022-02-09 19:20
I used to maintain a daily log of stuff I did at work with a single large "Diary.org" file - it had embedded lisp to make it work, and was all portable/self-contained. An [example file is here](https://github.com/skx/org-worklog), for reference. Recently I sat down and tried to make it a simple package, so that I could keep the actual content of the document more minimal. That lead to [org-diary](https://github.com/skx/org-diary). I'm not sure which is the better approach: * Force users to configure things in their init vs. * Keep everything in one file. Both have pros and cons, but on balance I'm thinking the "package" approach is perhaps more likely to be useful to others.
resixzem · 2022-02-10 08:25
Is it just my GNU Emacs? But the bottom part where it shows the command is kinda laggy. Usually I typed the whole thing before it shows what I typed like `C-x ...`.
kymki · 2022-02-10 10:19
The zotxt package and its connection to Zotero really was a gamechanger I should have looked into earlier than I did. Michael Behr wrote a nice post about it that is old, and is perhaps mentioned multiple times across the subreddit, but wth: [http://www.mkbehr.com/posts/a-research-workflow-with-zotero-and-org-mode/](http://www.mkbehr.com/posts/a-research-workflow-with-zotero-and-org-mode/)
kymki · 2022-02-10 10:20
Neat, I was just in the process of refactoring my workflow a bit so this comes in handy. Thanks for sharing.
nmtake · 2022-02-10 12:43
Take a look at `echo-keystrokes` variable.
resixzem · 2022-02-10 13:39
> echo-keystrokes Thanks for the answer. Relevant stackexchange: https://emacs.stackexchange.com/questions/29216/how-to-get-keystrokes-displayed-in-the-echo-area-immediately
bravosierrasierra · 2022-02-10 17:25
my lovely vterm companion for everyday use with many simultaneous opened projects in their perspective workspaces: per-directory vterm toggler/switcher, mapped on "s-s" (Option-s on my mac) ``` (defun bss/vterm-buffer (&optional arg) "Open new dedicated terminal for current buffer name at bottom with 1/3 original window height. If terminal already opened, then switch to it. If we on terminal, then switch to original buffer. With C-u close opened terminal and shell process" (interactive "P") (let* ( (buffer (buffer-name (current-buffer))) (is-vterm (string-prefix-p "*vterm" buffer)) (vterm-buffer-name (format "*vterm %s*" buffer)) (orig-buffer (if (string-match "\\*vterm \\(.*\\)\\*" buffer) (match-string 1 buffer) nil))) (cond ;; C-u - close opened terminal and shell process (arg (if is-vterm (select-window (get-buffer-window orig-buffer) nil)) (when (get-buffer-window vterm-buffer-name) (delete-window (get-buffer-window vterm-buffer-name)) (kill-buffer vterm-buffer-name))) ;; if term already opened, then switch to it ((get-buffer-window vterm-buffer-name) (select-window (get-buffer-window vterm-buffer-name) nil)) ;; if on terminal, then switch to original buffer (is-vterm (select-window (get-buffer-window orig-buffer) nil)) ;; open new terminal at bottom with 1/3 original window height (t (split-window-below (- (window-height) (/ (window-height) 3))) (other-window 1) (vterm) ;; (set-window-dedicated-p (get-buffer-window vterm-buffer-name) t) ) ) ) ) (global-set-key (kbd "s-s") 'bss/vterm-buffer) ```
eduardo · 2022-02-10 21:03
Using latest emacs-mac with Doom: something changed with ligature support (either in emacs or doom) that when a ligature is shown, now I get a "compact" version of the ligature. But if I put the point next to it, it grows to a normal size. Sorry, don't know how to explain myself. But this is causing my text to move around when navigating text. Anyone know what this is called or how to disable it?
SpringerJack · 2022-02-11 16:48
Have you disabled `prettify-symbols-mode`?
eduardo · 2022-02-11 17:08
Thank you! That was it!
oantolin · 2022-02-14 18:08
Oh, it looks like you could this function: (defun fix-lonely-parens () "Move all closing parenthesis at start of indentation to previous line." (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "^\\s-*)" nil t) (delete-indentation))))
bravosierrasierra · 2022-02-14 18:46
i'm preferred classical programming language indentation and grouping for my own code :)
oantolin · 2022-02-14 20:06
Well, it doesn't get much more classical than Lisp. :)
Phil-Hudson · 2022-02-15 11:47
Here's my attempt at a function for determining whether daylight savings time is in effect. I suspect there must be a simpler, more elegant solution out there. Anyway, it might be useful: (require 'dash) (defun ph/dstp () "Return non-nil if Daylight Saving Time (DST) is in effect." (not (-let* (((dstsm dstsd dstsy) (calendar-dst-starts (ph/current-year))) (dst-start `(,dstsy ,dstsm ,dstsd)) ((dstem dsted dstey) (calendar-dst-ends (ph/current-year))) (dst-end `(,dstey ,dstem ,dsted)) (today (reverse (seq-subseq (decode-time) 3 6)))) (-first (-not (-applify #'<=)) (-zip dst-start today dst-end))))) (defun ph/current-year () "Return the current year as a number." (caddr (calendar-current-date)))
BonfaceKilz · 2022-02-18 12:49
Hi! By default, my vterm buffers are named: "vterm<x>" where "x" is a number. Is there something you've done to have you buffers name differently?
BonfaceKilz · 2022-02-18 13:03
After some modifications, I've been able to make this work. Below is my snip: ``` (defun bonz/vterm-buffer (&optional arg) "Open new dedicated terminal for current buffer name at bottom with 1/3 original window height. If terminal already opened, then switch to it. If we on terminal, then switch to original buffer. With C-u close opened terminal and shell process" (interactive "P") (let* ( (buffer (buffer-name (current-buffer))) (is-vterm (string-prefix-p "*vterm" buffer)) (vterm-buffer-name (format "*vterm %s*" buffer)) (orig-buffer (if (string-match "\\vterm \\(.*\\)\\*" buffer) (match-string 1 buffer) nil))) (cond ;; C-u - close opened terminal and shell process (arg (if is-vterm (select-window (get-buffer-window orig-buffer) nil)) (when (get-buffer-window vterm-buffer-name) (delete-window (get-buffer-window vterm-buffer-name)) (kill-buffer vterm-buffer-name))) ;; if term already opened, then switch to it ((get-buffer-window vterm-buffer-name) (select-window (get-buffer-window vterm-buffer-name) nil)) ;; if on terminal, then switch to original buffer (is-vterm (select-window (get-buffer-window orig-buffer) nil)) ;; open new terminal at bottom with 1/3 original window height (t (let ((n (buffer-name))) (split-window-below (- (window-height) (/ (window-height) 3))) (other-window 1) (vterm) (rename-buffer (format "*vterm %s*" n))) )))) (global-set-key (kbd "s-s") 'bonz/vterm-buffer) ```
bravosierrasierra · 2022-02-18 13:15
vterm open buffer named by content vterm-buffer-name variable. I'm fill that variable before call (vterm).
shryzr · 2022-02-24 08:59
How’s this different from org-journal?