Flaky Goodness

Always Yes in Emacs Lisp

June 9, 2024

Some Emacs commands tend to ask too many confirmation questions, or at least it would be nice to have the option to skip the confirmation step. For example, saving and quitting a merge session in ediff requires quitting, confirming the quit, and then confirming the save.

I wanted to bind a single keystroke that would unconditionally commit my changes and end ediff. In the process, with the help of a coaching session from Prot, I made a general-purpose wrapper around any Emacs function to bypass confirmation.

(defun always-yes (&rest args)
  (cl-letf (((symbol-function 'yes-or-no-p) #'always)
            ((symbol-function 'y-or-n-p) #'always))
    (funcall-interactively (car args) (cdr args))))

I then used it to bind Q to unconditionally quit ediff, which requires a little more work than other packages typically would:

(defun my/ediff-quit-unconditionally ()
  (interactive)
  (always-yes #'ediff-quit))

(defun add-Q-to-ediff-mode-map () (define-key ediff-mode-map "Q" 'my/ediff-quit-unconditionally))
(add-hook 'ediff-keymap-setup-hook 'add-Q-to-ediff-mode-map)

This is a small improvement to be sure, but little quality of life improvements like this accrue over time. It’s one of the things I like most about Emacs.

All posts

2024-06-09Always Yes in Emacs Lisp
2024-05-29I Don’t Trust Parental Controls
2023-12-28Read-Only PDFs
2023-12-23Printing PostScript from Emacs in macOS Sonoma
2023-08-14Oven Fresh
2023-08-13Upgrading to Emacs 29.1 on Apple Silicon Macs
2022-04-10Upgrading to Emacs 28.1 on Apple Silicon (M1) Macs
2021-05-09Visual debugging for Swift Package Manager projects on Linux
2021-05-08Controlling TIDAL with AppleScript
2021-04-26Debug Swift Package Manager projects using dap-debug
2020-12-20Automatic switch for the macOS firewall
2020-12-06Multi-TTY support in Emacs 27
2020-05-27The Best Thing About eGPUs
2020-05-23Faster Dark Mode on macOS
2020-02-28Saving to Empty iCloud Drive Folders
2020-01-03Ensure Proper Ventilation
2019-10-06How to Lose Your Apple Health Data
2019-01-29How Many Conferences
2018-10-11Paste as Code
2018-06-09The iPad Productivity Paradox
2017-06-05Don't Give Up
2017-05-30Hey Siri on the Apple Watch
2017-03-31Networking at WWDC
2016-10-13Making Xcode more like Emacs
2016-02-10Three Products I Hope Apple Makes but They Probably Won't
2016-02-0714-day Week View in Calendar
2015-02-03Pile of Poo
2015-01-21My Priorities
2014-03-03My Problem with Objective-C Dot Syntax
2014-02-24Integrating terminal Vim with Finder [UPDATED 2015-02-10]
2013-07-07NIB-less
2013-06-30My RSS Setup
2013-05-01New Feed URL
2013-04-14The Creamiest TextView in the App Store
2013-04-11Using Panic's Status Board to monitor TimeTiger data
2013-04-07The Softphone that Gene Built
2013-03-29For the Most Part
2013-01-27Be Careful What You Start
2013-01-20User Intention
2013-01-13Unstuck
2013-01-06Archiving a TV News Segment
2012-12-30Pizza Segmentation
2012-12-23Spinning in Circles
2012-12-16Circling the Declarative Drain
2012-12-09How to Draw a Circle
2012-12-02Just Give Up Now
2012-11-25Native Mobile or HTML5
2012-11-18A Consumption Device
2012-11-11Best Enough
2012-11-04The Lifification of Games
2012-10-28Report the Bug
2012-10-21A User by Any Other Name
2012-10-14Getting Rid of Stuff
2012-10-07Start by Being Terrible
2012-09-30Taking Advantage of the Sum of Errors
2012-09-23An Alternative to QuickBooks
2012-09-16There and Back Again
2012-09-09Leader of the Pack
2012-09-023-day
2012-08-26Is Git useful at the beginning of a project?
2008-05-13Tables Anonymous