December 27, 2024

EmacsEmacs

Much Ado About Emacs 005

Tangling and Packages

In the last edition I had posted about a problem that I was facing. In short, when I deleted a package from my init file, the package was not deleted from the elpa directory where Emacs stores packages. I found that annoying. Having used Doom Emacs, a long time ago, I seem to remember that I didn’t do much else but delete the reference to the package in package.el. That got rid of the package, or at least I think it did. In my plain vanilla-setup, that was not happening.

There are two steps to the solution: Firstly you have to remove the use-package command from init.el. Secondly, M-x and type the command package-delete, select the package that you don’t want to use anymore and delete it by hitting ↵ (return). One good thing about this list, packages are listed as obsolete, dependencies or installed.

This two step process works out fine.

Notes and Note-taking

My note-taking needs are simple. They are:

  • I want to create and find notes quickly.
  • I would like to link between notes.
  • Tagging would be nice.

I am not looking for a graphical representation of my notes and the links between them. I don’t care to adhere to some knowledge management schema and its rules. In other words, I don’t care about atomic notes, fleeting notes, PARA, zettlekasten and all the other associated madness.

I don’t need denote, org-roam or howm. They are all great solutions. Not for me. Basic org-mode is all I need to create and access my notes. There are two things I added:

  1. An automatic Unique ID for all newly created org-files. I will talk about this in the next section.
  2. I brought back consult-notes. It is a nice interface to search for notes and gives me a preview of the note when selected. I like that.

Unique ID

I wanted an unique ID added to any org file I created. With help from Claude, I got this code for the unique ID:

#+begin_src emacs-lisp
;; First ensure org-id is loaded
(require 'org-id)

;; Configure org-id to create IDs using timestamps by default
(setq org-id-method 'ts)

;; Function to automatically add ID to new org files
(defun my/org-add-file-id ()
  "Add an ID property to the file if it doesn't have one."
  (interactive)
  (when (and (eq major-mode 'org-mode)
             (not (org-id-get-create)))
    (org-id-get-create)
    (save-buffer)))

;; Add hook to run when creating new org files
(add-hook 'org-mode-hook #'my/org-add-file-id)

;; Optional: Also ensure IDs are created for all headings
(defun my/org-add-ids-to-all-headings ()
  "Add IDs to all headings in current file that don't have one."
  (interactive)
  (org-map-entries 'org-id-get-create))

;; Optional: Add this to org-mode-hook if you want IDs on all headings
;; (add-hook 'org-mode-hook #'my/org-add-ids-to-all-headings)
#+end_src

This works great for newly created org files. Doesn’t work well with the capture templates that I have set up.

#+begin_src emacs-lisp
            ("b" "Bookmark" entry
           (file+headline "~/Dropbox/org/bookmark.org" "Bookmark")
            ,(concat "* %^{Title}\n"
                      ":CAPTURED: %U\n"
                      ":END:\n\n"
                      "%a\n%i%?")
           :empty-lines-after 1)
#+end_src

The capture template bails with an error-message which points out that org-id-get-create expects a specified buffer. I am working on trying to fix that, in the meantime, org-id-create is a manual process.

Multiple Cursor

I had this installed for two weeks and never used it once. Deleted it.

Try Package

Included Try in the configuration. Seems like a good way of trying out packages without fully committing to them.

Move the Scroll in Emacs Without Moving the Position Cursor.

Added Move the scroll in Emacs without moving the position cursor. to the configuration.

#+begin_src emacs-lisp
  (use-package scroll-page-without-moving-point
    :straight (:host github :repo "tanrax/scroll-page-without-moving-point.el" :files ("scroll-page-without-moving-point.el"))
    :ensure t)
(global-set-key "\C-n" 'scroll-page-without-moving-point-down)
(global-set-key "\C-p" 'scroll-page-without-moving-point-up)
#+end_src

That is all I have for this week. You can see I am having fun.

macosxguru at the gmail thingie.


emacs


Previous post
Much Ado About Emacs 004 When I started building my Emacs configuration, I copied bits and pieces of code from a whole host of other people’s configurations. It made it
Next post
2024 Review Two major changes happened over 2024. The introduction of the ZSA Moonlander Next-gen Ergonomics zsa.io to the hardware stack, and the other was GNU