reddit / emacs
Weekly Tips, Tricks, &c. Thread
AutoModerator · 2022-07-13 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.
Tohiko · 2022-07-13 11:33
In AUCTeX, is there a way to show some "compiling" symbol in the modeline during tex compilation? Does anyone have that in their config and is willing to share? If not, is there something similar for other languages that I can adapt?
tmting · 2022-07-13 12:38
I've been looking forward to use emacs as a bibliography manager, or alternatively find ways to integrate it into one. After searching a little bit, I found so much stuff that I'm finding myself a bit lost. Does anyone know a good guide, or would mind sharing their experiences so that I can understand a good way forward?
yigitemres · 2022-07-13 13:18
Did you look at this: https://github.com/emacs-citar/citar?
sachal_sarmast · 2022-07-13 14:23
I've got a workflow set up with using Zotero to pull references and pdfs from my browser, auto-populate a bibtex file and then use ivy-bibtex to insert references in either org files or tex files
There are ways to do this all internally in emacs, but I like how straightforward the Zotero connector is to use on Firefox or Chrome, how I can get it to manage my pdfs and it can automatically generate a bib file with any changes which I can see in Ivy bibtex almost immediately as well
gravygrowinggreen · 2022-07-13 14:29
I'd like to start writing fiction. To that end, I come seeking advice: what kind of setups do those who use emacs for long-form writing do? Perhaps more generally, is there a good module or method to set-up emacs for doing writing drills? (or any sort of drill-based practical activity for that matter)
EDIT: and that's a big doh, I forgot the most important question, the one I originally opened the thread up to ask. When using org-roam, is there a convenient way to manage multiple databases?
For instance, I run several DnD campaigns. I would like to set up an org-roam for each, and then be able to tell org-roam in session to only work on entries associated with that campaign. This would also be useful for the aforementioned fiction writing.
tmting · 2022-07-13 16:20
How are you integrating zotero and bibtex? Is it using that "Better Bibtex" thing?
I like this approach as I've used zotero before. So what you are doing is: zotero <-> bibtex <-> ivy-bibtex/emacs, right? So in this workflow, all the reference management happens inside zotero?
tmting · 2022-07-13 16:21
Gonna take a look. Thanks a lot!
population-zero · 2022-07-13 18:43
Why couldn't you just use tags to separate your entries by campaign?
C-x_M-c_M-butterfly · 2022-07-13 18:59
Was going to suggest the same thing. Could even make separate capture templates that auto-apply the appropriate tag (and maybe store in a separate subfolder if you need something like that)
MmmCurry · 2022-07-13 20:13
Seconding: I do something like this as well and like it a lot. Using bibtex as a bridge between Zotero and Emacs/Org lets you offload all the fiddly ingestion bits which Zotero does super well. The Better BibTex addon gets me a .bib file as output, and the .bib file just goes in my org repo and gets changes tracked like every other text file, so even if Zotero broke or dropped off the face of the earth after an update some day I could still recover and move on.
sachal_sarmast · 2022-07-13 21:31
That's right, I use the better bibtex add-on in Zotero and that produces the .bib file
grtcdr · 2022-07-13 22:45
I noticed `less-css-mode` has exactly this feature - it appears for the few seconds the stylesheets are compiling, and then disappears.
`less-css-mode` doesn't appear to be updating the modeline itself, [it seems it is relying](https://github.com/purcell/less-css-mode/blob/c7fa3d56d83206b28657f2e56439dc62280a2bf2/less-css-mode.el#L193) on the `compile` function which is part of [compile.el](https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/compile.el).
EDIT: Formatting.
WorldsEndless · 2022-07-13 23:03
I export orgmode to my blogs. However, when I have an underscore (like in a section header) it is interpreted as putting the next thing in a subscript. There are plenty of answers out there for disabling this globaly or for the whole file, but I WANT subscripts sometimes. How do I tell it to leave just a particular _ alone when I export?
yigitemres · 2022-07-13 23:22
You have to use `=_this_is_what_i_want_=`. But this is for single line. For multiline, you have to use `#+begin_example`block.
WorldsEndless · 2022-07-14 01:48
The = puts a different style on it (in-line code or something), but for my usecase that is no problem. Thanks! That works perfectly, even in heading lines!
mclearc · 2022-07-14 03:59
If you would find completion at point of citation keys helpful you could look at [https://github.com/gbgar/company-bibtex](https://github.com/gbgar/company-bibtex) or my port of it to use Emacs's native completion-at-point function [https://github.com/mclear-tools/capf-bibtex](https://github.com/mclear-tools/capf-bibtex).
Citar is great but might also be more than you need.
mclearc · 2022-07-14 04:02
You might look at the setup for [lambda-emacs](https://github.com/Lambda-Emacs/lambda-emacs), which is the framework I use for all my (mostly academic) writing, both long and short-form. I'm still working on making the framework more accessible to beginners/newcomers so I'm happy to answer any questions you might have.
gravygrowinggreen · 2022-07-14 04:50
I'll look into that. I think at some point I considered that, but thought it would be harder to filter out the entries from other campaigns/projects if they still happened to share tags.
For instance, if there is an entry tagged Campaign1 Strahd, and an entry tagged Campaign2 Strahd, would it be easy to avoid seeing the campaign 1 entry if I was currently running the second campaign?
gravygrowinggreen · 2022-07-14 05:18
I'm intrigued. Can I ask how you attempted to structure the notes and org-integration? I'm going to do a deep dive into lem-notes and lem-org-extensions tomorrow to see if I can puzzle your setup out.
yigitemres · 2022-07-14 06:52
Also I found this
https://emacs.stackexchange.com/questions/16688/how-can-i-escape-the-in-org-mode-to-prevent-bold-fontification
Tohiko · 2022-07-14 08:02
Ah nice. This will give me some code to look into. I doubt I can use the `compile` command since `AUCTeX` has custom commands for that.
Jack-o-tall-tales · 2022-07-14 13:19
There are two things you need to be able to do with a large collection of data (like a big bibliography): curate it, and access it.
Curation is where you manage the whole collection, and what you are primarily interested in interacting with is the data *itself*. Sorting, organising, etc.
Accessing is where you want to use one, two or a few particular pieces of that data (one or two references) in some other way. You might be writing a paper and want to insert a reference to something you have bibliographic data for.
The two operations are very different, and often require different software. Think about the difference between something like itunes (which shows you a complete list of all your music, and all the information about each piece (composer, label, etc.)) and the music-choosing menu on an early ipod (which just shows you a list of titles, organised to be as easy as possible to find what you want).
The best bibliography-manager is far and away [Ebib](http://joostkremers.github.io/ebib/).
The best access application will depend on your needs and setup, but [citar](https://github.com/emacs-citar/citar) is really excellent and is a great first bet.
The problem with having two different applications is that they don't automatically talk to each other, and might make different assumptions. Here are some sensible integrations. First, define a couple of variables which you can use in ebib and citar, for where you'll keep everything:
(defcustom my/bib-dir (expand-file-name "~/.papers/")
"Directory for bibliographies."
:group 'mine
:type 'file)
(defcustom my/bib-file (expand-file-name "papers.bib" my/bib-dir)
"Global biblatex reference file."
:group 'mine
:type 'file)
Then set:
* `ebib-preload-bib-files`, `citar-bibliography` and `bibtex-completion-bibliography` to `(list my/bib-file)`
* `bibtex-completion-library-path` to `my/bib-dir`
* `citar-library-paths` to `(list my/bib-dir)`
Then do whatever else you need for integrating with org/latex.
WorldsEndless · 2022-07-14 15:21
Thanks! I haven't looked too much into org entities, so that as an interesting solution. In my particular usecase, wrapping it in `=` is good. I catalogued the whole situation (and credited this thread) here: [https://orys.us/un](https://orys.us/un)
mclearc · 2022-07-14 15:34
Right now I have org-roam set up to use multiple directories and I search through notes with my [consult-notes](https://github.com/mclear-tools/consult-notes) package. I have [citar](https://github.com/emacs-citar/citar) set up to use in conjunction with bibtex and citar's ability to create reference notes via a custom org capture template. I may move away from citar in the future as I don't use all that much of its functionality (I use just a simple completion-at-point library -- https://github.com/mclear-tools/capf-bibtex)) but it is a great package.
You can see how I've set up org in the three org files in `lambda-setup`. If you like you can also look at my personal capture configuration [here](https://github.com/mclear-tools/dotemacs/blob/master/.local/lambda-library/lambda-user/cpm-setup-org.el).
organic-bookworm · 2022-07-15 12:52
https://www.reddit.com/r/emacs/comments/vxxyb8/comment/ig1npbh
tmting · 2022-07-15 16:44
Thanks a lot for the thorough answer my friend! Definitely gonna take a look at Ebib, this kind of integration sounds really interesting
tmting · 2022-07-15 16:44
Lol I really would miss that comment. Thanks!
No-Command-791 · 2022-07-15 21:04
I started using `eshell` today. The first thing I missed from `fish` was its auto-expanding [abbreviations](https://fishshell.com/docs/current/cmds/abbr.html) feature, which is easily replicated with `eshell-mode-abbrev-table` and the following advice:
(advice-add 'eshell-send-input :before #'expand-abbrev)
:-)
CulturMultur · 2022-07-15 22:07
Set `(setq org-export-with-sub-superscripts '{})` and underscores aren't exported as subscripts. When you want it to be exported as subscript, wrap them in {}, like `x_{i^2}`.
Check help for variable `org-export-with-sub-superscripts` for explanations.
​
Edit: formatting
haji-ali · 2022-07-15 22:50
I don't know if there's a better way to do this. But I frequently need to break long strings to some fixed width. So I came up with [this function](https://gist.github.com/haji-ali/3d8f4c28e21866e11a87b3e27476ad1c) (to be called inside a long string).
grtcdr · 2022-07-16 00:56
Hi,
It looks like someone has created a package that addresses this exact issue.
See: https://github.com/haji-ali/procress
I've not personally used it, I just saw the author's post on this subreddit and thought that I should let you know.
SpaceLaserBear · 2022-07-16 12:10
Put this in the Org file header to disable subscript
\#+options: \^:nil
WorldsEndless · 2022-07-16 21:26
This wasn't always the case, but I find that now emacs is ignoring some files when I do find-file. The most annoying example is .git not appearing, although I can navigate through it if I type it fully. This seems to happen whether I am using my vertico for find-file, or if I disable vertico and try using tab-completion in a raw find-files. How can I find out what is being ignored, and change/disable it? I would prefer to have nothing ignored by find-file. This is emacs 28.1 .
LemonBreezes · 2022-07-16 22:24
Thanks. I actually had intended to add this to my todo list.
_viz_ · 2022-07-17 03:20
completion-ignored-extensions.
_viz_ · 2022-07-17 07:07
Why do you need this? As long as you turn on abbrev-mode, you shouldn't need this advice. Typing a non-word key should expand the abbrev on the fly.
No-Command-791 · 2022-07-17 14:57
I execute most of my shell abbreviations without any additional arguments, and I guess `eshell-send-input` doesn't register as text input or something because typing an abbrev and hitting enter doesn't trigger the expansion.
LemonBreezes · 2022-07-18 13:25
Unless you type a space character before hitting enter, your last shell argument will not get expanded without this advice. I use abbrevs a lot to fix typos.
_viz_ · 2022-07-18 14:27
it expands on enter too which is why I asked. I assumed OP forgot to turn on abbrev-mode since I do it way too often and spend too much time scratching my head.
WorldsEndless · 2022-07-18 14:51
Brilliant! Thanks. Strange that customize reveals that variable to be part of the dired group.
_viz_ · 2022-07-18 15:03
that's probably because dired-omit-mode respects that variable
by_wicker · 2022-07-18 15:36
Does anyone know how to color the thin vertical gray lines alongside the scroll bars? [This is my scroll-bar between two windows](https://imgur.com/xCW4Z0Z). My fringe and scroll-bar background are invisible / same as background. I'm running of a recent `master` with pgtk.
I've tried messing with the faces for `fringe`, `scroll-bar`, and `vertical-border` - they don't seem to be involved.
Does anyone know how I can modify that line?
WorldsEndless · 2022-07-18 23:49
My command doesn't write when it's executed by a keystroke or by `M-x`, but it does when I just evaluate it with `C-x C-e`. Nonetheless, both command actually WORK -- they just don't print. Why?
(defun tsa/change-volume (amount-str) (interactive)
(shell-command (concat "pactl set-sink-volume 0 " amount-str))
(shell-command-to-string "pactl get-sink-volume 0")
; "Volume: front-left: 55865 / 85% / -4.16 dB, front-right: 55865 / 85% / -4.16 dB
; balance 0.00
;"
)
(defun tsa/vol+ () (interactive) (tsa/change-volume "+5%"))
; (Shell command succeeded with no output)
shaky_noise · 2022-07-19 01:03
You can try customizing `window-divider-first-pixel` and `window-divider-last-pixel`.
by_wicker · 2022-07-19 11:36
Good thought, thanks, though I also tried those, and my divider is turned off.
nicholas_hubbard · 2022-07-19 14:07
Nothing major but putting this at the top of your config will make debugging config errors easier by entering the debugger when an error is encountered when starting emacs.
(toggle-debug-on-error)
(add-hook 'after-init-hook 'toggle-debug-on-error)
LemonBreezes · 2022-07-19 21:54
I just tested OP's advice and indeed, the advice is necessary for the expansion to occur for Eshell.
meain · 2022-07-21 14:47
Doesn't `fill-paragraph` do the same thing?
haji-ali · 2022-07-21 16:20
It doesn't do that in lisp for me. I needed a function that would break a long string \`"..."\` and add or remove backslashes where needed.
7890yuiop · 2022-07-23 04:14
You haven't written any code which would print anything.
> it does when I just evaluate it with C-x C-e.
C-x C-e runs the command eval-last-sexp
Evaluate sexp before point; print value in the echo area.
Interactively, with a non `-' prefix argument, print output into
current buffer.
bdarcus · 2022-08-03 19:05
Just a little thing: neither citar nor ebib require bibtex-completion.
Citar did at one time, but hasn't for awhile.
Jack-o-tall-tales · 2022-08-03 19:23
Thanks!
takeonrules · 2022-09-20 02:52
Have I got some stuff for you! With a similar concern, multiple contexts:
https://github.com/jeremyf/dotemacs/blob/394ce8e55d62f18d8615dc9a798970e458310a84/emacs.d/knowledge-management-config.org#org-roam
The idea is that you set a context (e.g. a list of tags). And then the wrappers for org roam find, insert, and create nodes will filter on those tags.
So, when I'm playing in the Burning Locusts campaign, I set the context and all of my Org Roam queries/interactions filter on the tags for that campaign.
And if I want to link between contexts, I just turn off the contexts and create/find my links.
Here's a blog post that also dives into this: https://takeonrules.com/2022/02/07/org-roam-emacs-and-ever-refining-the-note-taking-process/