reddit / emacs
Weekly Tips, Tricks, &c. Thread
AutoModerator · 2022-03-02 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.
robotreader · 2022-03-02 13:10
Lists and quoting have always sort of confused me, so I'm hoping someone can help explain how to do this.
I'd like to map my `org-todo-keywords` to `svg-tag-mode` tags.
`svg-mode` tags are set like this:
(setq svg-tag-tags
'((":TODO:" . ((lambda (tag) (svg-tag-make "TODO" ))))))
And org-mode-keywords is a list of strings.
SasukeUchiha231 · 2022-03-02 13:24
I have [todo.org](https://todo.org) in my project roots, how can i make org agenda read from those if i'm in the project? Or should i not have [todo.org](https://todo.org) per project?
ground_ginger · 2022-03-02 14:01
A few weeks ago I asked a [question](https://www.reddit.com/r/emacs/comments/sijcap/comment/hvb8koq) about running a fully interactive zsh instance in org-babel blocks. I got something working that serves my purpose, so I thought I'd share it.
It's an [awk script](https://pastebin.com/Czdhh5Vm) that sends the commands to a zsh instance running in a headless tmux session. At the end it captures the pane contents so that these can be the contents of the results block.
I haven't created a babel executor specifically for this script. Right now I just use `shell` blocks with `:output results` and `:shebang` set to the path of my awk script.
This works well enough to demo the history expansion snippets in my personal zsh notes. I also tested it with simple multiline commands like loops and conditionals. It's handling those as well.
karthink · 2022-03-02 15:39
Add `org-agenda-files` as a dir local variable at the root of your project.
rguy84 · 2022-03-02 19:19
[Posted in Org-mode](https://www.reddit.com/r/orgmode/comments/szkzf6/two_unrelated_questions_pasting_into_excel_and/) last week, and hoping to get some insight still.
Status-Detective-783 · 2022-03-03 08:45
I saw your question. Didn't someone answer question 1? If so, you should edit your text to indicate that one was answered. Also, you'll get more eyes on it posting it in this sub.
_viz_ · 2022-03-03 09:18
> Didn't someone answer question 1?
That reply was posted around 1.5 hours before your reply here.
rguy84 · 2022-03-03 13:11
As u/\_viz\_ said, that reply happened not tool long before your comment, about 14 hours after I made the comment here, also it was 2am when they posted.
[deleted] · 2022-03-03 18:11
[deleted]
Status-Detective-783 · 2022-03-03 18:12
Oops. I hope my tone didn't sound off, I was really just trying to be helpful. And of course, you're absolutely right, I should check timestamps for suggesting such a thing. I guess since it was posted a week ago, I didn't expect that any reply would have been very recent... just assumed it was an old reply.
Status-Detective-783 · 2022-03-03 18:16
Oops, you're right. I'll definitely check time-stamps before suggesting any such a thing. Ironically, the mistake was mine and not OP's! (And also ironically, "somebody" learned something here!)
vanpop_ · 2022-03-03 20:52
There is too for nix that allows to prefetch hash for package sources called [nix-prefetch](https://github.com/msteen/nix-prefetch), i wrote wrapper around it that allows me sending any region from emacs to it and inserting hash under point
(require 'cl-lib)
(defun my/nix-prefetch-hash (start end)
"Pass buffer content between START and END to \"nix-prefetch\" and insert output.
When called interactively pass selected region if mark is active or entire buffer
otherwise."
(interactive (if mark-active
(list (region-beginning) (region-end))
(list (point-min) (point-max))))
(let* ((progress (make-progress-reporter "Fetching nix hash..."))
(command (executable-find "nix-prefetch"))
(content (shell-quote-argument
(buffer-substring-no-properties start end)))
(output (shell-command-to-string
(format "%s -q %s" command content)))
(err-match (string-match ".*error:.*" output)))
(cond (err-match
(message
(substring output err-match (string-match "\n" output err-match))))
((string-prefix-p "warning: found empty hash" output)
(progn
(insert (string-trim (cl-second (split-string output "\n"))))
(progress-reporter-done progress)))
(t
(progn
(insert (string-trim output))
(progress-reporter-done progress))))))
oantolin · 2022-03-03 21:51
I answered, but only after seeing the link here!
wskydev · 2022-03-03 23:37
If you ever want to kill a buffer in the other window without having to move to that window, kill the buffer, then move back, this snippet will make it easy to do that. I find this useful when dealing with error message buffers (or any other buffers that get produced).
(defun kill-buffer-other-window ()
"Kill buffer in the other window."
(interactive)
(other-window 1)
(kill-buffer (current-buffer))
(other-window 1))
(global-set-key (kbd "C-x M-k") 'kill-buffer-other-window)
[deleted] · 2022-03-04 04:29
[deleted]
yousufinternet · 2022-03-04 04:33
If I keep hitting the right arrow key in the minibuffer until I hit the end of the line, the cursor will exit the minibuffer and hitting `M-x` or `:` will show:
args out of range: #<buffer: *Minibuf-1*>, nil
and minibuffer becomes totally inaccessible, and I have to restart emacs which is very annoying.
I use evil-mode BTW
Status-Detective-783 · 2022-03-04 04:42
I'm having a problem with list-packages.
I do `M-x list-packages`. I want to install several packages, the first is beeminder. So I type `/ n beeminder RET` to display the beeminder package. Great, I type `i` and it's marked for installation. Then `/ /` to get back to the main list so I can hunt for more packages to install. But now, beeminder is no longer marked for installation.
I should think that `/ /` should only affect my view, and not remove the `I` install designation. Am I wrong?
GNU Emacs v. 27.2
I posted it a couple days ago [here](https://www.reddit.com/r/emacs/comments/t3wn6b/problem_with_listpackages_package_menu_command/), but it didn't get any traction so I figured I'd repost here, I hope that's ok.
github-alphapapa · 2022-03-04 08:07
Quoting shouldn't be relevant here. What you probably need to do is something like this:
(setq org-todo-keywords (mapcar (lambda (tag) ...) svg-tag-tags)
github-alphapapa · 2022-03-04 08:10
If this happens in a clean Emacs config, then you should probably ask on emacs-devel or file a bug report.
Status-Detective-783 · 2022-03-04 08:20
Thanks!
robotreader · 2022-03-04 15:17
Thanks for the response! i want to generate svg-tag-tags based on org-mode-keywords, not the other way around. do I just need to switch those two names?
yousufinternet · 2022-03-04 17:28
I checked `*Messages*` buffer and this is clearer:
turn-on-undo-tree-mode: Args out of range: #<buffer *Minibuf-1*>, nil
whompyjaw · 2022-03-07 00:57
is it generally common practice to have a single \`\`\`\` [todo.org](https://todo.org) file at root? i am using doom emacs, and there is a command that gathers all your todo's into 1 buffer. (But i think the files need to be under an \`org\` directory... not sure yet.
SasukeUchiha231 · 2022-03-07 03:36
I use doom emacs too! and that's why i asked this question. I changed my workflow to have an org roam node per project, and have a keybinding that automatically brings the org roam node according to the project i'm in. Let me know if you would like the config
[deleted] · 2022-03-07 11:19
I know that emacs's entire schtick is being a highly extensible editor, but how is it if you _don't_ like configuration?
whompyjaw · 2022-03-07 15:24
Hmm. I haven’t tried messing with Org Roam yet. But sure, feel free to share it if you’d like :)
Rotatop · 2022-03-08 06:45
Even good framework need configuration, or maintenance
I recommand to not use emacs in this case (and I know visual code is pretty good without configuration and still highly extensible)
karthink · 2022-03-09 05:15
Couple of alternatives:
- `ace-window` lets you kill any window on the frame the same way you'd switch to it.
- I use `popper` to deal with showing/hiding error message buffers etc, which also lets you kill them "remotely".
pwnedary · 2022-03-09 13:09
I suggest you just try it out. Since you do not initially plan to do any custom configurations it will suffice to just take each Emacs distro out for a spin such as Doom etc.
Phil-Hudson · 2022-03-13 22:05
Can't remember where I got this, but here's what I have:
(defun kill-buffer-in-other-window (skip-count)
"Kill the buffer in the other window.
Argument SKIP-COUNT is the number of windows to skip."
(interactive "p")
(kill-buffer (other-window-buffer skip-count)))
Phil-Hudson · 2022-03-13 22:10
1. Probably better to ask this on [Stack Exchange](https://emacs.stackexchange.com)
2. It would help to have a trivial example of desired input and output mappings.
robotreader · 2022-03-14 04:25
1. Perhaps, but I’ve always found this community knowledgeable and happy to help.
2. I provided an example of the output, but I don’t know what the correct output of the actual question would look like, hence me asking
Phil-Hudson · 2022-03-15 10:49
OK, the first thing that strikes me is those double open-parens before that `lambda` look strange. Also, the lambda takes an argument `tag` which it does not use.
I know nothing about svg-mode, so the following is all just based on general principles.
Are you perhaps trying to build a cons cell (a "dotted pair", a list of the form `(a . b)`) containing ":TODO:" and the result of evaluating that lambda? If so, you can do it thus:
(cons ":TODO:" (svg-tag-make "TODO"))
or equivalently using the backquote syntactic sugar:
`(":TODO:" . ,(svg-tag-make "TODO"))
robotreader · 2022-03-17 08:16
> Are you perhaps trying to build a cons cell (a "dotted pair", a list of the form (a . b)) containing ":TODO:" and the result of evaluating that lambda? If so, you can do it thus:
I'm not sure whether it's supposed to be a cons cell or not, but it needs to contain the lambda itself, not the result. When svg-tag-mode finds a match, it will evaluate that lambda and substitute the result.
Flabellate · 2022-03-19 06:34
Like org-projectile? Nice, I’d like to take a look, please
SasukeUchiha231 · 2022-03-20 11:25
Made a github repo:
[https://github.com/Ice-Cube69/org-project-manager](https://github.com/Ice-Cube69/org-project-manager)
Do open an issue if you have any problems cause this is my first plugin.
Phil-Hudson · 2022-03-25 06:04
Try removing those outer parens around the `lambda`.