November 21, 2024

EmacsEmacs

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:

  1. Still using god-mode. I am liking it.
  2. Using consult-notes but considering moving to org-roam.
  3. 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.
  4. 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


Previous post
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
Next post
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