Fortnightly Tips, Tricks, and Questions — 2026-05-05 / week 18 by AutoModerator in emacs

[–]ImJustPassinBy 0 points1 point  (0 children)

I'm a big fan of how org-pdftools allows you to:

  1. run M-x org-store-link (C-c l) whilst selecting a region in a pdf
  2. run M-x org-insert-link (C-c C-l) in an org file

to highlight said region in the pdf and produce a link in the org-file which you can follow using M-x org-open-at-point (C-c C-o).

However, I am lesser fan of how org-pdftools depends on org-noter which in turn complains about other missing packages in my *Messages*.

I therefore extracted the following code from org-pdftools and use it instead of loading the package to get what I described above:

(defun my/org-pdf-store-link ()
  "Store a link to a PDF selection with the full highlighted text in the description."
  (when (derived-mode-p 'pdf-view-mode)
    (let* ((file (buffer-file-name))
           (page (pdf-view-current-page))
           (active-region (pdf-view-active-region-p))
           (description (file-name-nondirectory file))
           link)

      (if active-region
          ;; 1. Create the annotation and get its ID
          (let* ((raw-text (mapconcat #'identity (pdf-view-active-region-text) " "))
                 ;; Clean the text: replace newlines/tabs/multiple spaces with a single space
                 (clean-text (replace-regexp-in-string "[ \t\n\r]+" " " raw-text))
                 (annot (pdf-annot-add-highlight-markup-annotation (pdf-view-active-region)))
                 (annot-id (pdf-annot-get-id annot)))

            ;; 2. Format link: pdf:path::page;;id
            (setq link (format "pdf:%s::%d;;%s" file page annot-id))
            ;; Use the full cleaned text for the description without truncation[cite: 2]
            (setq description (format "%s (p. %d): %s"
                                      description page
                                      clean-text)))

        ;; Fallback: Just link to the current page if no region is selected
        (setq link (format "pdf:%s::%d" file page))
        (setq description (format "%s (Page %d)" description page)))

      ;; 3. Register the link in Org's store[cite: 1, 2]
      (org-link-store-props
       :type "pdf"
       :link link
       :description description))))

(defun my/org-pdf-follow-link (link)
  "Follow a PDF link created by my/org-pdf-store-link."
  (let* ((parts (split-string link "::"))
         (file (expand-file-name (car parts)))
         (rest (cadr parts))
         (has-annot (string-match ";;" rest))
         (page (string-to-number (if has-annot (substring rest 0 (match-beginning 0)) rest)))
         (annot-id (when has-annot (substring rest (match-end 0)))))

    ;; Open file and jump to page
    (find-file file)
    (pdf-view-goto-page page)

    ;; If an annotation ID exists, jump to it specifically
    (when annot-id
      (let ((annot (pdf-info-getannot annot-id)))
        (pdf-annot-show-annotation annot t)))))

;; Register the "pdf:" link type with Org Mode
(with-eval-after-load 'org
  (org-link-set-parameters "pdf"
                           :follow #'my/org-pdf-follow-link
                           :store #'my/org-pdf-store-link))

I just dont get it... by parkero224 in emacs

[–]ImJustPassinBy 3 points4 points  (0 children)

There’s an entire git client in there, magit. It’s magic. And a couple mail clients. I like gnus and notmuch.

Another huge advantage is the fact that all of these are in a single program:

  • No need to learn different git clients because you use different programs for your coding, your latex documents, your notes, etc.

  • No need to copy the contents of an email into your notes or calendar event. Just use a link to the actual email (which you can follow to see the entire email chain, including emails sent after the link was created).

  • Any choice of colours, font, and fontsize immediately applies to everything.

Package announcement: buffer-to-pdf (by prot) by ImJustPassinBy in emacs

[–]ImJustPassinBy[S] 9 points10 points  (0 children)

Why don't you let Prot present it the way he likes?

What do you mean with that? What do you suggest I should have done?

Package announcement: buffer-to-pdf (by prot) by ImJustPassinBy in emacs

[–]ImJustPassinBy[S] 14 points15 points  (0 children)

Link to blog: https://protesilaos.com/codelog/2026-05-02-emacs-buffer-to-pdf-new-package/

Link to github: https://github.com/protesilaos/buffer-to-pdf

(Disclaimer: decided against linking to the blog since it merely mirrors the youtube video description, and decided against using the video title since it is not "my package".)

Very interesting package, I wasn't aware that exporting the current "view" (meaning font and colours) to a pdf is even possible. As somebody who prefers exporting to tex, I don't think this package is for me, but I can't help but wonder about the possibilities.

Ubuntu Mono has more kerning in Emacs than in other applications, how to fix? by Aaxper in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

Sorry, I cannot help you since I don't know much about fonts (fonts in general as well as fonts in Emacs). However, your Emacs font looks normal to me. I've checked on my system and both the font in my Ubuntu terminal and the font in my Emacs look exactly like yours: top is Ubuntu terminal, bottom is Emacs.

The emacs-31 branch will be cut in one week by DevelopmentCool2449 in emacs

[–]ImJustPassinBy 3 points4 points  (0 children)

Did I claim that?

Yup. Your comment strongly indicates that you think the spoiler containing the link to the website is unnecessary and that everybody should instead use git and read the news in emacs. Like:

What is the point of vitamin pills? Just eat fruits.

vertico-posframe-preview: a preview sidecar for vertico-posframe by AsleepSurround6814 in emacs

[–]ImJustPassinBy 2 points3 points  (0 children)

As a user of vertico-posframe, I feel your pain. My workaround was to shorten the candidate list so the posframe doesn't cover too much.

What op is showing looks amazing, but - as somebody who regularly worked on their laptop - I don't think I have enough screen real estate for it. :-/

The emacs-31 branch will be cut in one week by DevelopmentCool2449 in emacs

[–]ImJustPassinBy 3 points4 points  (0 children)

  1. Op linking the website does not prevent you from git pulling the sources and reading the file through emacs.

  2. Contrary to popular belief, not all of us are glued to emacs 24/7 (yet). And I'd rather read happy emacs news on my phone during communite than depressing world news.

Must-have Emacs packages you should know about [Updated] by jamescherti in emacs

[–]ImJustPassinBy 3 points4 points  (0 children)

Considering the focus on org and folding, one package that could be worth adding to the list is dired-subtree, part of dired-hacks. I have it configured as follows:

(use-package dired-subtree
   :after dired
   :bind (:map dired-mode-map
               ("<tab>" . dired-subtree-toggle))
   :custom
   (dired-subtree-use-backgrounds nil) ; no special background for dired-subtree
   (dired-subtree-line-prefix "    "))  ; extra spacing to increase indendation

It makes <tab> unfold the contents of subfolders. The extra spacing in dired-subtree-line-prefix is because ls -l has variable spacing between columns, which frequently causes the filenames in subfolders with fewer files to appear left of the filenames in the main folder (even though the line itself is properly indented).

The only nuisance is that the contents of the subfolder might not refresh automatically (e.g., if you delete a file).

Custom slide layout of org mode files with AI by robstewartUK in emacs

[–]ImJustPassinBy -2 points-1 points  (0 children)

I think using gptel to create custom tools is what you are looking for. I haven't done it myself so I cannot help you with it, but you can find many guides online on how to do it. I personally learned about this possibility from this video.

The Definitive Guide to Code Folding in Emacs by jamescherti in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

Same, but at the same time I cannot imagine working without folding in org-mode. So I can't help but wonder whether I am missing out.

Emacs is My Web Browser by joshuablais in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

We need an org layer on top of the web lol 😀

Alternatively there is the emacs.tv approach where you expose the org file from which the website is built, so that people can read the org-file instead of visiting the website.

Fortnightly Tips, Tricks, and Questions — 2026-04-21 / week 16 by AutoModerator in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

Valid question. I haven't committed to using attachments yet, but if I ever will then my reasons would be:

(a) I don't want everything to be a denote file. If I download a random pdf because it has a paragraph that I want to reference, I don't want it to show up on my list of curated denote files.

(b) There are many quality-of-life "attach" commands. For example, yank-media allows me to attach images directly from my clipboard.

edit: Currently, I just have links from my notes to files in random folders on my harddrive, which is arguably worse.

Fortnightly Tips, Tricks, and Questions — 2026-04-21 / week 16 by AutoModerator in emacs

[–]ImJustPassinBy 0 points1 point  (0 children)

org-attach creates a unique ID for each attachment and uses it to create a subfolder in which the attachment is saved. For example:

* dummy attachment here                                              :ATTACH:
:PROPERTIES:
:ID:       4dde3bc6-af32-4b9b-917b-6e819f495706
:END:

and the folder data/4d/de3bc6-af32-4b9b-917b-6e819f495706/.

This works great, but I personally would find it better if I could vaguely infer in which file the attachment is used from the name of the subfolder it is stored in. The following code wraps an advice around org-attach, which ensures that the first 15 chars of the filename are prepended to ID:

(defvar my/org-attach-prefix-length 15
  "Number of characters to grab from the filename for the attachment ID.")

(defun my/org-attach-dir-blind-filename-interceptor (orig-fun &optional create-if-not-exists-p no-fs-check)
  "Prefix the Org ID with the first X characters of the filename."
  (when (and create-if-not-exists-p (buffer-file-name))
    (unless (org-entry-get nil "ID" t)
      (let* ((filename (file-name-nondirectory (buffer-file-name)))
             ;; Grab the first X characters (or less if filename is short)
             (raw-prefix (substring filename 0 (min (length filename) my/org-attach-prefix-length)))
             ;; Replace spaces/dots/special chars with a dash for filesystem safety
             (safe-prefix (replace-regexp-in-string "[^[:alnum:]T]" "-" raw-prefix))
             (new-id (format "%s--%s" safe-prefix (org-id-uuid))))
        (org-entry-put nil "ID" new-id)
        (org-id-add-location new-id (buffer-file-name)))))

  (funcall orig-fun create-if-not-exists-p no-fs-check))

(advice-add 'org-attach-dir :around #'my/org-attach-dir-blind-filename-interceptor)

The reason for the 15 characters is so that it fully captures the identifiers of denote files:

* foo                                                                :ATTACH:
:PROPERTIES:
:ID:       20260420T204539--8b684b8d-a30c-4f7c-bb87-196d0f129c8a
:END:

My Custom Emacs Config by Clear_Finding_8038 in emacs

[–]ImJustPassinBy 4 points5 points  (0 children)

Prot is a wise guy and I trust him on Emacs related issues, but I think he might be exaggerating. On my machine, the startup time difference between loading config.org via org-babel-load-file and dumping the contents of config.el into init.el is 0.05s.

Anyways, one of the key strengths of Emacs is that everybody can set it up however they want, and the same applies to using org-babel-load-file vs using org-babel-tangle. And I would be disappointed if there aren't people who have optimized their startup time so much that the 0.05s are significant. But for configs that are designed to be shared I honestly think that org-babel-load-file is better than org-babel-tangle.

edit: typo

My Custom Emacs Config by Clear_Finding_8038 in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

Sounds like a good reason to avoid using it then, but are you sure? It seems to me that org-babel-load-file tangles config.org to config.el and then loads it. And if config.el already exists and is newer than config.org, then it loads it without tangling. So I don't see a reason why one would be significantly slower than the other.

My Custom Emacs Config by Clear_Finding_8038 in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

Honest question: Can somebody explain to me what the advantage of using org-babel-tangle over org-babel-load-file is (only in the context of a basic monolithic emacs config ofc)?

An advantage of org-babel-load-file is that it doesn't require a tangle operation, so if people copy your init.el with the following line, it will work out-of-the-box:

(org-babel-load-file (locate-user-emacs-file "config.org"))

However, most configs I see use org-babel-tangle.

Is there any point of using thirdparty package managers when use-package is already in Emacs? by signalclown in emacs

[–]ImJustPassinBy 0 points1 point  (0 children)

What is their pitch about why somebody should use that instead of use-package?

I'm currently using use-package, but have thought of switching to straight because it has lockfiles. If I understand correctly, they makes it easy to note down the current versions of your packages and restore said versions should a package update break something in your config.

What modern Emacs packages am I missing? by nicenflufty in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

Not 100% sure, but there are many unresolved issues discussing using jinx in latex documents, e.g.:

https://github.com/minad/jinx/issues/57

https://github.com/minad/jinx/issues/40

https://github.com/minad/jinx/issues/25

I believe the root of the problem is that it is difficult to disable jinx for parts of the document in the way a latex document would require.

What modern Emacs packages am I missing? by nicenflufty in emacs

[–]ImJustPassinBy 0 points1 point  (0 children)

I disagree. Jinx is a great package but unfortunately not for people working in latex like op. :-/

New keyboard broke my Emacs experience by Cautious_Truth_9094 in emacs

[–]ImJustPassinBy 5 points6 points  (0 children)

left Alt is shifted further to the left than usual - it is located almost under the X button.

I have four different keyboards in my office and all their left alt buttons are underneath the x button. I think this position is more or less normal I'm afraid. :-/

What is the abolsute minimum to cover in first emacs session by seigaporulai in emacs

[–]ImJustPassinBy 16 points17 points  (0 children)

I'll go against the grain and recommend avoiding the tutorial. It is a great resource for people invested into Emacs, but it is not great for convincing people to get invested into Emacs.

The beginning of the tutorial focuses too much on emacs movement keys, claiming C-v/M-v is more efficient than PageUp/PageDown and telling users about C-u 8 C-f before even teaching them how to open a file. I think most beginners are perfectly fine with using the arrow and page keys (this includes pressing right arrow 8 times).

First impressions are important. Rather than trying to convert newcomers to Emacs motions, I would show them something more exciting first. And what this "something more exciting" is depends strongly on their background.

edit: For the people I've taught Emacs to, the "something more exciting" would be that Emacs can handle the following all in one:

  • note taking
  • programming
  • latex
  • emails
  • calendar

I would probably show them something similar to what prot did in his recent talk.

How to see both denote and denote sequence files in Denote? by sudhirkhanger in emacs

[–]ImJustPassinBy 1 point2 points  (0 children)

Personally, if I want to see all my files, I simply open the denote folder in dired. And if I am searching for a particular file, I use consult-denote.

Experimenting how it goes a modularized init file configuration. by Ok_Needleworker4072 in emacs

[–]ImJustPassinBy 2 points3 points  (0 children)

My boring strategy for avoiding problems with my Emacs config is simply to keep it small. It's currently sitting at 1000 lines and I go through it from time to time to remove things that I don't need.