February 4, 2025

EmacsEmacs

Much Ado about Emacs 007

Working away in Emacs. This is an interesting and fun exercise. Learning new stuff. Playing with packages. Configuring Emacs. Need to calm down and use the product instead of spending all the time in making the environment better. This seems to be a never-ending exercise. Need knowledge. That is going to be the focus next. RTFM. Both for Emacs and Emacs lisp. Should be fun. Okay, you needn’t snicker. This is all the fun that is healthy at my age.

Defining the Look of Org-Levels and Markdown Header Faces

Using modus-operandi-theme and I didn’t like the look of the org-headers in it. Tried to change the look and decided that Markdown headers could also use a change.

#+begin_src emacs-lisp
  (custom-set-faces
   '(org-level-1 ((t (:inherit variable-pitch :height 1.1 :weight bold))))
   '(org-level-2 ((t (:inherit variable-pitch :height 1.1 :weight bold))))
   '(org-level-3 ((t (:inherit variable-pitch :height 1.1 :weight bold))))
   '(org-level-4 ((t (:inherit variable-pitch :height 1.1 :weight bold))))
   '(markdown-header-face-1 ((t (:inherit variable-pitch :height 1.1 :weight bold))))
   '(markdown-header-face-2 ((t (:inherit variable-pitch :height 1.1 :weight bold))))
   '(markdown-header-face-3 ((t (:inherit variable-pitch :height 1.1 :weight bold))))
   '(markdown-header-face-4 ((t (:inherit variable-pitch :height 1.0 :weight bold)))))
  (setq markdown-header-scaling-padding 1.0) ; Add padding around headers
#+end_src

Quick Window Pt. 4

James Dyer is busy. He is tweaking the functionality of his quick-window-jump function. Emacs Quick Window Pt 4 - Further Tweaks · Emacs@ Dyerdwelling. I am following along, trying to learn from what he is doing.

Marked 2

Howard Melman, clued me in to the following:

#+begin_src emacs-lisp
(defun my/my-open-Marked ()
  "Open the current file in Marked 2."
  (interactive)
  (if (not buffer-file-name)
      (error "Must be visiting a file")
    (call-process-shell-command (format "open -a \"Marked 2\" \"%s\"" buffer-file-name))))
#+end_src

Check Parenthesis

When I am trying to write elisp, or trying to edit my configuration, I often struggle with parenthesis. This is a piece of elisp I got Claude.ai to generate for me.

#+begin_src emacs-lisp
(defun check-parens-in-file (filename)
  "Check parenthesis matching in specified file.
Returns t if all parentheses match, nil otherwise.
Also shows detailed error location if mismatches are found."
  (interactive "fFile to check: ")
  (with-temp-buffer
    (insert-file-contents filename)
    (emacs-lisp-mode)
    (condition-case err
        (progn
          (check-parens)
          (message "All parentheses match correctly!")
          t)
      (error
       (message "Parenthesis mismatch found: %s" (error-message-string err))
       nil))))
#+end_src

I run it on an elisp buffer to find out whether the parenthesis are matched.

Sundry Items

  • I am using Denote. Not certain that I need to, but it is nice and I am using it.
  • Still considering a move away from god mode to evil-mode. Little intimidated by the inevitable introduction of a new learning curve to the whole exercise. Things are working out for me with plain-vanilla Emacs and god mode, do I really need to complicate this exercise? What are the pay-offs? Not sure about that. That is what is keeping me from switching. Looking at other people’s configuration files leads me to the conclusion that general.el is fantastic when you are in evil-mode. You can organize commands in a way which makes sense to you. I love what people are doing with that. Like I said, I am intrigued, but hesitant. I moved away from god mode. But haven’t moved into evil-mode yet.
  • I am slowing down on the configuration and getting into the act of reading the manual on Emacs. Need to know what is possible before I blunder into more changes. Have a system here which is good enough. I don’t know what perfection is. So it doesn’t make much sense to chase it. I will come back to it when something bugs me.

Found this interesting: How Emacs changed my life PPT

macosxguru at the gmail thingie.

emacs
January 27, 2025

iconicon

Leader Key

If you are looking for a program which helps your interaction with macOS, you should consider Alfred or/and Keyboard Maestro. If you don’t want to spend money or introduce an interesting alternative to help you launch files and do other stuff with macOS, LeaderKey.app, is a new entrant. It is open-source and free.

An Alternative Way

Both Alfred and Keyboard Maestro are primarily keyboard shortcut driven. For instance, I have a whole series of keyboard commands set, in Alfred, to launch programs in macOS.

⌃+⇧+C: Launches Google Chrome
⌃+⇧+E: Launches Emacs
⌃+⇧+M: Launches SpamSieve and Mail, and so on.

You run out of keyboard commands if you use this feature. Alfred of course has the option of typing the name of the application, folder, and a whole host of items if you need that. But if you like keyboard commands, you are going to do what I have to do.

⌃+⇧+B: Launches BBEdit
⌃+⇧+⌥+B: Launches Better Rename

Introduce keyboard commands which let you use the same launch letter for different programs.

Keyboard Maestro gives you the option of a palette. You can assign the same keyboard commands to a whole host of launchers and that will bring up a palette. You choose the option you are looking for, by typing a character to choose your desired option. This is a better option than Alfred.

Leader Key is built on a similar vein. I set it up to launch with ⌘+.. Leader Key lets you form groups of commands. I have set up a group which is activated by typing ‘o’, then I type another letter to get the app I want to launch. I type ‘oe’ to launch Mail. ‘ow’ for Emacs. ‘ot’ for Ghostty, and so on.

PreferencesPreferences

You can have sets of keyboard input to launch applications, URL’s, commands and folders. The arrangement ensures that you are not going to run out of keyboard commands.

Leader Key is well-designed and capable of being a solution for your launching needs.

Caveats

Use the Choose option to pick the application you are going to assign. Sequoia has internally changed the path of where the programs are stored. In the Finder, it looks like they are all in the Applications folder. However, their paths show different locations. For example, the path to Safari is "/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app", while the path to Messages is "/System/Applications/Messages.app". Strange.

The configuration for Leader Key can be set through the program’s preferences. It can also be edited as a .json file. .json is not the most malleable text format. You have to be mindful of the presence and absence of commas that the format requires.

Suggested Improvements

  1. The input box for the path of the application does not let you paste the path of the application, you have to type it in. I use the Choose option and that lets me not worry about pasting in the path. I would have liked to be able to paste in the path.
  2. Would have loved it if I could assign multiple applications to the same keyboard command. I work in sets of programs. Launching them together would make sense to me. I do this in both Alfred and Keyboard Maestro. Leader Key doesn’t let me do that.
  3. Would like the preferences to be sort-able. The static order it shows is the order you added the programs in. Would have loved the ability to show it sorted. I added the programs I wanted, then opened the .json file in Emacs and re-ordered the settings to be alphabetically sorted. That is my way around this mess.

SortedSorted

  1. I am trying to integrate Leader Key with Alfred’s workflows and system commands. Haven’t been successful in the attempt so far. I see it works with Raycast.

Conclusion

Leader Key is a worthy addition to the macOS toolset. Recommended without any reservations.

macosxguru at the gmail thingie.

PS: Video from the developer The faster than your launcher launcher – Leader Key for macOS - YouTube

macOS
January 21, 2025

AwwwAwww

Links of Note 2025-01-21

macosxguru at the gmail thingie.

Thanks to: Photo by Pixabay: https://www.pexels.com/photo/close-up-photo-of-cute-sleeping-cat-416160/

macOS font editor
January 13, 2025

ToolsTools

App Defaults 2025

This was inspired by App Defaults ldstephens and he was inspired by Hemispheric Views - App Defaults.

Mail Client: Mail()
Mail Server: Gmail
Spam: SpamSieve
Notes: Emacs
To-Do: Emacs and Reminders()
Project-management: Emacs
Diary/Journal: Emacs
iPhone Photo Shooting: Camera+ Pro Camera & Editor
Photo Management: Photos()
Image Manipulation: Acorn 8
Music Player: Music (), Swinsian
Calendar: Calendar()
Contacts: Contacts()
Cloud File Storage: iCloud(), and Dropbox
RSS: Newsblur, NetNewsWire, Emacs
Browser: Safari(), Chrome
Chat: Messages(), Telegram
Bookmarks: pinboard.in, Emacs
Read It Later: Emacs
Reading epubs: ClearView X, Kindle
Reading pdf’s: Reader, PDF Expert
Podcast: Podcasts()
Text: Emacs, iA Writer, BBEdit
Markdown Previewer: Marked 2
Launcher: Alfred
Spreadsheets: Numbers()
Shopping Lists: Emacs
Password Management: Enpass
Weather: Weather()
File Rename: Better Rename
File Search: HoudahSpot
Netword Security: Little Snitch
File Management: Hazel
Macros: Alfred, Keyboard Maestro
Clipboard: Alfred
Snippets/Text-expansion: Alfred
Keep computer awake: Amphetamine
Delete Apps: AppCleaner
Crosswords: Black Ink 2
Calculator: PCalc, Calca
Youtube Downloader: Downie
File Dump: EagleFiler
Terminal: Ghostty
Video-player: IINA
Compressor/uncompressor: Keka
Window Management: Moom
Quicklook: Peek
Mindmaps: Scapple, Emacs
Screenshot: ScreenFloat
Writing Everything: Emacs

macosxguru at the gmail thingie.

Thanks to: Photo by cottonbro studio: https://www.pexels.com/photo/silver-and-blue-metal-tools-4480531/

macOS
January 2, 2025

EmacsEmacs

Much Ado about Emacs 006

These are some of the things which got my attention last week.

Constraining the movement of the cursor in the mini-buffer

The cursor in the mini-buffer needs to be constrained from moving around. Errant arrow-keys make life difficult. This is the solution, from the documentation of Daniel Mendler’s Vertico package:

#+begin_src emacs-lisp
  (setq minibuffer-prompt-properties
        '(read-only t cursor-intangible t face minibuffer-prompt))
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
#+end_src

Get rid of ^M

I have the need to copy some file names in the Finder and paste into an org-mode buffer.

This is what happens:

Evil fuckersEvil fuckers

What are these ^M characters? Did some research and they seemed to be DOS line-ending markers. What? DOS? Confused the hell out of me. I don’t have that in BBEdit. What is going on? More research led to this solution.

#+begin_src emacs-lisp
(defun dos2unix ()
  "Replace DOS eolns CR LF with Unix eolns CR"
  (interactive)
    (goto-char (point-min))
      (while (search-forward (string ?\C-m) nil t) (replace-match "\n")))
#+end_src

I run the dos2unix function to get rid of these evil things.

Outliner minor mode for everything

I love org-mode because it lets me have outliner behavior in my text editor. Like folding, hoisting, and so on. I got exposed to outline-minor-mode and decided to bring that to Markdown. The keybindings need work but this is what I am starting with:

#+begin_src emacs-lisp
(add-hook 'markdown-mode-hook 'outline-minor-mode)
;; Define outline-minor-mode key map
  (define-prefix-command 'cm-map nil "Outline-")
  (define-key outline-minor-mode-map (kbd "C-c @") 'cm-map)

  ;; Define key bindings for outline minor mode
  (define-key cm-map (kbd "t") 'outline-hide-body)     ; Hide all but headings
  (define-key cm-map (kbd "a") 'outline-show-all)      ; Show everything
  (define-key cm-map (kbd "c") 'outline-hide-entry)    ; Hide this entry's body
  (define-key cm-map (kbd "e") 'outline-show-entry)    ; Show this entry's body
  (define-key cm-map (kbd "l") 'outline-hide-leaves)   ; Hide all body lines
  (define-key cm-map (kbd "k") 'outline-show-branches) ; Show all entries
  (define-key cm-map (kbd "q") 'outline-hide-sublevels); Hide everything but top-level
  (define-key cm-map (kbd "o") 'outline-hide-other)    ; Hide other branches
#+end_src

reveal-in-osx-finder

Looking at some transients Howard Melman sent me, I came across a reference to reveal-in-osx-finder. Shows you the file you are working on in the Finder. Useful.

#+begin_src emacs-lisp
(use-package reveal-in-osx-finder)
(require 'reveal-in-osx-finder)
(global-set-key (kbd "C-c z") 'reveal-in-osx-finder)
#+end_src

cycle-spacing

Ran across this in Precise Word Spacing in macOS Emacs. It is a problem I face quite often and now I have a solution:

#+begin_src emacs-lisp
(keymap-global-set "M-SPC" #'cycle-spacing)
#+end_src

Transients and General

I use General for assigning my own keybindings to org-mode and markdown-mode. The default keybindings are too elaborate. General is not helpful if you don’t know what the options are that are available to you. Transients are handy in the process of discovery. The act of creating the transients helps you get familiar with the options that you can access. Howard Melman clued me in to the efficiency of this addition. Two examples of what he pointed me to.

Transient for C-x r

#+begin_src emacs-lisp
;;;; Transient for C-x r - rectangles, registers, bookmarks
(defun hrm-list-bookmarks ()
  (interactive)
  (call-interactively 'bookmark-bmenu-list))
(transient-define-prefix hrm-ctl-x-r-transient ()
  "Transient for C-x r commands"
  ["C-x r …"
   ["Rectangles"
    ("M-w" "Copy" copy-rectangle-as-kill)
    ("k" "Kill" kill-rectangle)
    ("y" "Yank" yank-rectangle)
    ("d" "Delete" delete-rectangle)
    ("o" "Open" open-rectangle)
    ("c" "Clear" clear-rectangle)
    ("t" "String" string-rectangle)
    ("N" "Number" rectangle-number-lines)
    (":" "Sum Down" calc-grab-sum-down) ; Unnecessary since I add it to rectangle-mark-mode-map
    ]
   ["To Register"
    ("SPC" "Point" point-to-register)
    ;; ("C-SPC" "Point" point-to-register)
    ;; ("C-@" "Point" point-to-register)
    ("s" "Region" copy-to-register)
    ("a" "Region Append" append-to-register) ; unbound
    ("p" "Region Prepend" prepend-to-register) ; unbound
    ("r" "Rectangle" copy-rectangle-to-register)
    ("w" "Window Config" window-configuration-to-register)
    ("f" "Frameset" frameset-to-register)
    ("n" "Number" number-to-register)
    ("+" "Increment" increment-register)
    ("K" "KMacro" kmacro-to-register)     ; C-x C-k K, can be here too
    ]
   ["From Register"
    ("j" "Jump" jump-to-register)
    ("i" "Insert" insert-register)
    ("x" "Consult" consult-register :if (lambda () (fboundp 'consult-register)))
    ]
   ["Bookmarks"
    ("m" "Set" bookmark-set)
    ;;("b" "Jump" bookmark-jump)        ; I bind C-x r b to consult-bookmark
    ("b" "Jump Consult" consult-bookmark)
    ("l" "List" hrm-list-bookmarks) ; list-bookmarks fails, probably because of call-interactively
    ("M" "Set if Unset" bookmark-set-no-overwrite)
    ("S" "Save" bookmark-save)
    ]
   ]
  )

(global-set-key (kbd "C-x R") #'hrm-ctl-x-r-transient)

#+end_src

Transient for M-g

#+begin_src emacs-lisp
      (transient-define-prefix hrm-goto-transient ()
        "Transient for navigation commands on M-g."
        ["Goto"
         ["Position #"
          ("g" "Line"             consult-goto-line)
          ("c" "Char"             avy-goto-char-timer)
          ("TAB" "Column"         move-to-column)
          ("t"  "Window Top/Bot"  move-to-window-line-top-bottom)
          ]
       ["Index Here"
        ("i" "Imenu"          consult-imenu)
        ("o" "Outline"        consult-outline) ; goto outline-regexp matches
        ("h" "Org Heading"    consult-org-heading :if-mode org-mode)
        ("m" "Mark"           consult-mark)     ; goto marker in mark-ring
       ]
     ["Index All"
      ("I" "Project Imenu"  consult-imenu-multi)
      ("M" "Global Mark"    consult-global-mark)
      ("T" "All Todo"       consult-todo-all)
      ]
    ["Here in"
    ("D" "Dired"   dired-jump)
    ("B" "IBuffer" ibuffer-jump)
    ("S" "Shell"   shell)       ; eshell?
    ("R" "Finder"  reveal-in-osx-finder :if (lambda () (fboundp 'reveal-in-osx-finder)))
    ]
   ["Avy"
    ("l" "Line" avy-goto-line)
    ("w" "Word" avy-goto-word-0)
    ("W" "Prompted Word" avy-goto-word-1)
    ]
  ])
      (global-set-key (kbd "M-G") 'hrm-goto-transient)
#+end_src

Lists of Some Other Changes

  • I installed the Spacemacs theme. I like the light version of the theme.
  • Also installed the Standard themes from Protesilaos. Love the light theme there.
  • Installed the Nano theme from Rougier. It is an impressively minimal look.
  • Installed the Embark package. Have little idea of what it does. I am reading up on it. Will discuss when I have a better idea of what that package is good for.

As you can tell, I am having fun and learning some new stuff.

Till next time.

macosxguru at the gmail thingie.

emacs