;; I recommend (global-set-key (kbd "S-SPC") 'ph/delete-whitespace)
(defvar ph/delete-whitespace-counter 0)
(defvar ph/delete-whitespace-counter 0)
(defun ph/delete-whitespace (arg)
(interactive "*p")
(if (eq this-command last-command)
(progn
(incf ph/delete-whitespace-counter)
(if (= ph/delete-whitespace-counter 1)
(delete-blank-lines)
(join-line arg)))
(setq ph/delete-whitespace-counter 0)
(just-one-space arg)))
What other idempotent commands which deserve their own combination like this?
jmmcd posted a correction on reddit, and a recommendation for home and end to go to the next line if repeated. Here's a quick hack for that:
ReplyDelete(defun ph/home-or-prev ()
(interactive)
(if (eq last-command 'ph/home-or-prev)
(progn (previous-line)
(beginning-of-line))
(back-to-indentation)))
(defun ph/end-or-next ()
(interactive)
(if (eq last-command 'ph/end-or-next)
(progn (next-line)
(end-of-line))
(end-of-line)))
A minor change -- should use (eq this-command last-command) instead of explicitly stating the command name.
ReplyDelete