December 4, 2024
Emacs
Much Ado about Emacs 003
I am enjoying living in Emacs. Getting to know it better.
These are some of the changes I have made since the last time I wrote about Emacs:
- Moved from Consult-notes to Org-roam. Not sure that this move is permanent. I am trying out Org-roam to find out what it adds.
- I am sticking to god-mode. I tried out evil The extensible vi layer for Emacs. The problem is that I am still learning Emacs and everything gets more complicated with the introduction of Vim keybindings. Better off sticking to vanilla Emacs. Learn how that works and then I might consider evil-mode.
- Trying out hydra make Emacs bindings that stick around. Not sure that I like it all that much but I am overwhelmed with all the keyboard commands I am trying to learn. Hydra helps with that.
- I use NewsBlur for my RSS feeds. But I am reading Emacs related news in Emacs through elfeed An Emacs web feeds client. I can feel Emacs slowly taking over all of my computer tasks. Which leads me to the next addition.
Atomic-Chrome
From Mike Zamansky Using Emacs 40 - atomic-chrome - YouTube. Installed the Chrome extension, Chrome Emacs, and the following package. I can use Emacs to fill in text frames in Chrome.
#+begin_src emacs-lisp
(use-package atomic-chrome
:demand t
:straight (atomic-chrome
:repo "KarimAziev/atomic-chrome"
:type git
:flavor nil
:host github)
:commands (atomic-chrome-start-server)
:config (atomic-chrome-start-server)
(setq-default atomic-chrome-buffer-open-style 'frame)
(setq atomic-chrome-default-major-mode 'markdown-mode)
(setq atomic-chrome-extension-type-list '(atomic-chrome))
(setq-default atomic-chrome-auto-remove-file t))
#+end_src
Killing a word at point
This is from: Some Excerpts From My Emacs Config - 2: Functions - The Emacs Cat
#+begin_src emacs-lisp
(defun kill-whole-word ()
"Kill the current word at point."
(interactive)
(backward-word)
(kill-word 1))
(define-key global-map (kbd "<M-DEL>") #'kill-whole-word)
#+end_src
Nuke all buffers
This is useful sometimes. From: Some Excerpts From My Emacs Config - 2: Functions - The Emacs Cat
#+begin_src emacs-lisp
(defun nuke-all-buffers ()
"Kill all buffers, leaving *scratch* only."
(interactive)
(mapc
(lambda (buffer)
(kill-buffer buffer))
(buffer-list))
(delete-other-windows))
#+end_src
Multiple-cursors
I am trying out multiple-cursors. magnars/multiple-cursors.el: Multiple cursors for emacs.
#+begin_src emacs-lisp
(use-package multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-S-l C-S-l") 'mc/edit-beginnings-of-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
#+end_src
Make C-g a little more useful
Protesilaos is a fantastic resource for Emacs users. Emacs a basic and capable configuration Protesilaos Stavrou has some nice additions. This is one of them.
This is the explanation from Protesilaos:
“Do-What-I-Mean behaviour for a general keyboard-quit'. The generic
keyboard-quit’ does not do the expected thing when the minibuffer is open. Whereas we want it to close the minibuffer, even without explicitly focusing it. The DWIM behaviour of this command is as follows:
- When the region is active, disable it.
- When a minibuffer is open, but not focused, close the minibuffer.
- When the Completions buffer is selected, close it.
- In every other case use the regular `keyboard-quit’.”
#+begin_src emacs-lisp
(defun prot/keyboard-quit-dwim ()
(interactive)
(cond
((region-active-p)
(keyboard-quit))
((derived-mode-p 'completion-list-mode)
(delete-completion-window))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(t
(keyboard-quit))))
(define-key global-map (kbd "C-g") #'prot/keyboard-quit-dwim)
#+end_src
Do not show warnings
I needed this. The warnings were scaring me. From Emacs a basic and capable configuration Protesilaos Stavrou.
#+begin_src emacs-lisp
(add-to-list 'display-buffer-alist
'("\\`\\*\\(Warnings\\|Compile-Log\\)\\*\\'"
(display-buffer-no-window)
(allow-no-window . t)))
#+end_src
That is all I want to talk about today. See you next time.
macosxguru at the gmail thingie.
emacs
November 21, 2024
Emacs
Much Ado About Emacs 002
It is overwhelming, what you need to learn to be able to use Emacs well. The operative word here is “well.” I can use Emacs badly. In the sense, that what is taking me some effort to achieve might be possible to do quicker and more efficiently if only I knew how to improve the process.
I guess, the knowledge and understanding of Emacs will grow over time. The trick is to keep at it. It is overwhelming how much I don’t know about Emacs.
Focus on New Window
I am trying to move away from tabs and rely on windows to move between files. I think I will end up using a combination of the two. There are some files which I need to be open and easily accessible. For instance, the diary file and the todo file. These can be two tabs. The third tab can be where I open windows, switch to a buffer, work on it, and then delete the window when I am done.
I ran into a problem with windows. When you open a new window, the focus of the cursor stays on the original buffer. Doesn’t make sense to me, but that is the default behavior. I wanted the focus to shift to the window that I just created.
I got the solution from Terencio Agozzino.
#+begin_src emacs-lisp
(use-package window
:ensure nil
:preface
(defun hsplit-last-buffer ()
"Focus to the last created horizontal window."
(interactive)
(split-window-horizontally)
(other-window 1))
(defun vsplit-last-buffer ()
"Focus to the last created vertical window."
(interactive)
(split-window-vertically)
(other-window 1)))
(global-set-key (kbd "C-x C-1") #'delete-other-windows)
(global-set-key (kbd "C-x C-2") #'vsplit-last-buffer)
(global-set-key (kbd "C-x C-3") #'hsplit-last-buffer)
(global-set-key (kbd "C-x C-0") #'delete-window)
#+end_src
Much better.
Balanced vs. Golden Ratio
My configuration included the following:
#+begin_src emacs-lisp
(use-package balanced-windows
:config
(balanced-windows-mode))
#+end_src
This meant that new windows were roughly the same size as the existing window. It was working fine but I found an alternative.
romangolden-ratio.el Automatic resizing of Emacs windows to the golden ratio made sure that the new window was the main focus and had a much bigger size than the original window. I like it. This is the code I am using for it.
#+begin_src emacs-lisp
(use-package golden-ratio)
(golden-ratio-mode 1)
#+end_src
Update: Jack Baty has a warning about the golden-ratio package. I have been using it for a couple of weeks with no problems, but you might want to be careful.
Showing Folders in a Dired Buffer on the Top
I wanted the dired buffer to show folders at the top of the listing. Protesilaos Stavrou’s configuration comes to the rescue.
#+begin_src emacs-lisp
(setq dired-listing-switches
"-AGFhlv --group-directories-first --time-style=long-iso")
#+end_src
Scratch buffers in org-mode or markdown-mode
When I am working in my Emacs.org configuration file, I want a scratch buffer in org-mode to try out some things. I also want a markdown-mode buffer when I am writing in Markdown. This is the package which lets me do that.
emacs-weirdwarescratch Mode-specific scratch buffers - Codeberg.org
The relevant code:
#+begin_src emacs-lisp
(use-package scratch)
(global-set-key (kbd "C-c s") 'scratch)
#+end_src
Updates:
- Still using god-mode. I am liking it.
- Using consult-notes but considering moving to org-roam.
- Reading the org-mode manual. Org-mode is the main reason I switched to Emacs. Would be nice to be able to use this well.
- I have expressed the intention to stop tweaking Emacs and concentrate on using the features I know about. Not going to happen. Emacs is a wet-dream for anyone interesting in tinkering with their environment. I am, apparently one of them. The more I get exposed to different things about Emacs, the more I find myself incorporating those into my configuration and giving it a go. At this stage, it is endless tinkering.
macosxguru at the gmail thingie.
emacs
November 18, 2024
Crossroads
Different Path
It occurs to me that the usual content of the blog has changed significantly in the previous few months. I don’t write about the newest Markdown based text editor that has been released. I write about some macOS stuff. But mainly I write about Emacs.
I don’t see that changing much in the near future. I have moved on from Obsidian, VSCode and the others into Emacs. I have BBEdit and iA Writer installed. I use them for specific things. BBEdit is my comfort blanket. It is there to remind me that if I get overwhelmed by Emacs, there is a tool which I can use to solve my current problem. iA Writer is there to provide me with its syntax checker and easy syncing with my iPhone.
I am not interested in the newest addition to the plethora of text editors which deal with Markdown. I use Emacs for that. Completely immersed in Emacs, I don’t have the energy to check some new editor out. Thus the content of the blog is going to change to focus on what I am working on and using. Sorry if you miss the previous focus.
macosxguru at the gmail thingie.
Thanks to: Photo by Emiel Vansteenbrugge
macOS
writing
emacs
November 12, 2024
completely unnecessary cat picture
Links of Note 2024-11-11
macosxguru at the gmail thingie.
Note: Thanks to Photo by Tranmautritam
macOS
emacs
bbedit
October 29, 2024
Emacs
Much Ado about Emacs 001
This is going to be a recurrent series on my working in Emacs. I will write about what I am trying, adopting, and discarding. The rationale or the benefits behind the decisions. The goal is two pronged:
- It might help people going through the same process.
- It will help me understand the changes I am making to the configuration of Emacs and my workflow in it.
god-mode
god-mode is a major change to the way I interact with Emacs.
I am using the ZSA Moonlander as my keyboard and was having trouble with the continual mashing of the Ctrl key and the Alt key while using Emacs. I tried to change the location of those keys to get rid of the fatigue that comes from contorting my hands to reach them. Didn’t help. God-mode solves that problem.
Not interested in switching to evil-mode, or doom yet, it made sense to try out god-mode as an alternative. I specially liked this feature in god-mode:
All existing key bindings will work in God mode. It’s only there to reduce your usage of modifier keys.
Using it for a week now. Still getting used to it, but I must point out that not reaching for the Ctrl key and the Alt key makes the process of using Emacs easier on my wrists. Will use this for a couple of months before I decide on continuing to use this or switching to evil-mode. Have to give it a reasonable amount of time to embed itself in my muscle memory.
This is my setup for god-mode.
#+begin_src emacs-lisp
(use-package god-mode)
(god-mode)
(global-set-key (kbd "<escape>") #'god-mode-all)
(setq god-exempt-major-modes nil)
(setq god-exempt-predicates nil)
(global-set-key (kbd "C-x C-1") #'delete-other-windows)
(global-set-key (kbd "C-x C-2") #'vsplit-last-buffer)
(global-set-key (kbd "C-x C-3") #'hsplit-last-buffer)
(global-set-key (kbd "C-x C-0") #'delete-window)
(defun my-god-mode-update-cursor-type ()
(setq cursor-type (if (or god-local-mode buffer-read-only) 'box 'bar)))
(add-hook 'post-command-hook #'my-god-mode-update-cursor-type)
#+end_src
A New Mode line
I was using the mode line from Sophie Bosio. It was impressively minimal. I wanted some more information displayed. Being slightly familiar with doom-modeline
. I decided to switch to it. The result is still minimal but it does contain the information I want.
This is what I am using:
#+begin_src emacs-lisp
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1)
(setq doom-modeline-height 25)
(setq doom-modeline-bar-width 4)
(setq doom-modeline-hud nil)
(setq doom-modeline-window-width-limit 85)
(setq doom-modeline-project-detection 'auto)
(setq doom-modeline-buffer-file-name-style 'truncate-nil)
(setq doom-modeline-icon t)
(setq doom-modeline-major-mode-icon t)
(setq doom-modeline-major-mode-color-icon t)
(setq doom-modeline-buffer-state-icon t)
(setq doom-modeline-buffer-modification-icon t)
(setq doom-modeline-buffer-name t)
(setq doom-modeline-highlight-modified-buffer-name t)
(setq doom-modeline-column-zero-based t)
(setq doom-modeline-percent-position '(-3 "%p"))
(setq doom-modeline-position-line-format '("L%l"))
(setq doom-modeline-position-column-format '("C%c"))
(setq doom-modeline-position-column-line-format '("%l:%c"))
(setq doom-modeline-minor-modes nil)
(setq doom-modeline-enable-word-count 1)
(setq doom-modeline-continuous-word-count-modes '(markdown-mode gfm-mode org-mode))
(setq doom-modeline-buffer-encoding nil)
(setq doom-modeline-indent-info nil)
(setq doom-modeline-total-line-number 1)
(setq doom-modeline-vcs-icon nil)
(setq doom-modeline-check-icon t)
(setq doom-modeline-check-simple-format nil)
(setq doom-modeline-number-limit 99)
(setq doom-modeline-workspace-name nil)
(setq doom-modeline-persp-name nil)
(setq doom-modeline-display-default-persp-name nil)
(setq doom-modeline-persp-icon nil)
(setq doom-modeline-lsp nil)
(setq doom-modeline-github nil)
(setq doom-modeline-modal t)
(setq doom-modeline-modal-icon t)
(setq doom-modeline-modal-modern-icon t)
(setq doom-modeline-always-show-macro-register nil)
(setq doom-modeline-mu4e nil)
(setq doom-modeline-gnus nil)
(setq doom-modeline-buffer-file-name-function #'identity)
(setq doom-modeline-buffer-file-truename-function #'identity))
(use-package nerd-icons
:custom
(nerd-icons-font-family "Symbols Nerd Font Mono"))
#+end_src
Turning Off M-Ret From Splitting the Line
M-return
continues a list in org-mode. You have to get to the end of the line and press it to get a new list item. That was a pain. This code makes it possible to press the keyboard command wherever you are in the line and it gives a new list item after the one you were on.
I did not write this. Unfortunately I don’t remember where I got it from. Sorry. Need to do a better job of documenting the source of ideas. The code is:
#+begin_src emacs-lisp
(setq org-M-RET-may-split-line '((item . nil)))
#+end_src
macosxguru at the gmail thingie.
emacs