Sunday, August 2, 2026

Some emacs lisp utilities of mine, that have been useful for me.

Several utilities to ease the pain of working with a  single monitor

Working on a small monitor, like a laptop screen, can be a strain.  To make this easier, I wrote some utilities in emacs lisp.  Another one was written by someone named "Gildea" on a mailing list.  They have been useful to me; perhaps they will be useful to others.  They are simple, and certainly could be improved upon. 
 
First open a second window, horizontally (\C-x3).  Then use the first functoin to enlarge one of the windows horizontally.  It is hardwired to enlarge, horizontally, by 20 character widths, which can be changed. One can just as easily change the sizes of windows by dragging with a mouse.
 

I.   Enlarge one of two horizontally split windows

(defun enlarge-window-very-horizontally ()
  "Enlarge this window horizontally."
  (interactive)
  (enlarge-window-horizontally 20))
 

II.  Flip flop: Move to other window and swap widths.

This utility does two things: it moves the cursor to the other window; and it swaps the sizes of the two windows.    
 
(defun flip-flop-and-change-horizontal-windows ()
  "Swap HORIZONTAL window sizes; move into the other window.  This function
enables one to have two windows visible, but with one very narrow."
   (interactive)
   (let ((current-window-width (window-width)) 
     (new-window-width nil)
     (delta-window-width nil))
     (other-window 1)
     (setq new-window-width (window-width))
     (setq delta-window-width (- current-window-width new-window-width))
     (enlarge-window-horizontally delta-window-width)))

 

 III.  Flip flop vertically (like the above)

This version works with vertically split windows.  This might work better in some cases.  These utilities are minimal, written by a naive emacs user.  I feel certain they can be modified and improved in various ways.  I would like to find a way that the tool above, for horizontally split windows, can move back and forth, even when either or both sides is split into two or more windows vertically.  They sky's the limit, but these utilities are simple, and therefore easy to use and remember.

 

(defun flip-flop-and-change-windows ()
  "Swap window sizes; move into the other window.  This function
enables one to have two windows visible, but with one reduced to two lines."
   (interactive)
   (let ((current-window-height (window-height)) 
     (new-window-height nil)
     (delta-window-height nil))
     (other-window 1)
     (setq new-window-height (window-height))
     (setq delta-window-height (- current-window-height new-window-height))
     (enlarge-window delta-window-height)))
 

IV.  Swap positions of two windows with contents. 

 Another tool was written by a "Gildea" on a mailing list in 1988, possibly in answer to a query of mine.  It enables one to just swap the positions of two whole windows. 
 
 (defun swap-window-positions ()
  "Swap the positions of this window and the next one.
(credit to gildea Nov 88)"
  (interactive)
  (let ((other-window (next-window (selected-window) 'no-minibuf)))
    (let ((other-window-buffer (window-buffer other-window))
      (other-window-hscroll (window-hscroll other-window))
      (other-window-point (window-point other-window))
      (other-window-start (window-start other-window)))
      (set-window-buffer other-window (current-buffer))
      (set-window-hscroll other-window (window-hscroll (selected-window)))
      (set-window-point other-window (point))
      (set-window-start other-window (window-start (selected-window)))
      (set-window-buffer (selected-window) other-window-buffer)
      (set-window-hscroll (selected-window) other-window-hscroll)
      (set-window-point (selected-window) other-window-point)
      (set-window-start (selected-window) other-window-start))
    (select-window other-window)))


 I hope these are useful, as they have been useful to me.

CachyOS

 At this time I would just like to note that I have been using CachyOS exclusively for a couple of months.  An earlier iteration didn't work for me, at the time of the great Archlinux Nvidia debacle that made it functionally impossible for someone with my limited expertise to use my GTX 1050 card.  Too old.  It works, but no longer supported.  

 

As of earlier this year, however, CachyOS automatically chooses the correct older driver version to run this card.  No wonder it climbed up to the top of the hit list on DistroWatch.  I think deservedly so.  I understand that it will also run other cards---the 1650 series-albeit with some manual intervention.  I hate that term, but I would love to have one of those.  My system works quite well, and I was grateful that an NVIDIA card had drivers, even proprietary, that work really well.  I am opposed to proprietary drivers, but I admit I have been using several for years, because I cannot just go and change my hardware choices every time I would like.  I home built, on the cheap, with a nice CPU, some good amount of RAM, good storage, and at least some kind of affordable video card.  It hurts that companies can just decide it's not worth it to support hardware that's little more than 10 years old.  IMO, it's criminal.  PT Barnum had something to say about this.  Basically we are the suckers.  Next time, will there ever be a next time, I will probably go with AMD.  Corporate decisions don't work out for the consumer.  

 

That said, this old card is doing its job.  -

 

-----------------------

 

It's been a few months since I wrote the above.  The system is still running nicely.   I have noticed one thing: updates, which I like to run every so often, take quite long on this system, as opposed to my Thinkpad with it's Intel graphics, because the kernel must be compiled together with the Nvidia bits, on every update.  Even with a 26 core Intel i7, this takes a good long time.  It's worth the wait.  

 

 

  

Some emacs lisp utilities of mine, that have been useful for me.

Several utilities to ease the pain of working with a  single monitor Working on a small monitor, like a laptop screen, can be a strain.  To ...