help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

don't hard-code keys


From: Emanuel Berg
Subject: don't hard-code keys
Date: Sun, 02 May 2021 00:35:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Here are two interesting functions for several reasons...

But the question: how can I avoid hard-coding the C-u key but
instead have the keybinding inserted thru a reference to the
function, i.e. `universal-argument'?

I don't plan to rebind C-u and/or use something else for
universal-argument, rather I'd like to just not have the C-u
hard-coded for personal/political reasons.

(defun open-irc (&optional connect)
  (interactive "P")
  (let ((irc-buffer (car (erc-buffer-list))))
    (if irc-buffer
        (progn
          (switch-to-buffer irc-buffer)
          (erc-scroll-to-bottom-no-blanks))
      (if connect
          (irc-connect-to-all)
        (message "did nothing, C-u to connect") )))) ; [1]

(defun new-message (&optional force)
  (interactive "P")
  (message (format "%s" force))
  (if (or (not (eq major-mode 'message-mode)) force)
      (progn
        (unless (gnus-alive-p) (gnus))
        (gnus-post-news 'post "") )
    (message "did nothing, C-u to force") )) ; [2]

[1] https://dataswamp.org/~incal/emacs-init/erc-incal.el
[2] https://dataswamp.org/~incal/emacs-init/gnus/gnus-incal.el

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]