Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
;; Hack around bug in Emacs 25 described in https://emacs.stackexchange.com/a/41889/15483
(cond
((< emacs-major-version 26)
;;
;; Backport Emacs 26 version of mark-whole-buffer to include the call to (goto-char (minibuffer-prompt-end)) below
;;
;; Original Emacs 25 version is in /usr/share/emacs/25.2/lisp/simple.el.gz
;; and contains:
;;
;; (defun mark-whole-buffer ()
;; "Put point at beginning and mark at end of buffer.
;; If narrowing is in effect, only uses the accessible part of the buffer.
;; You probably should not use this function in Lisp programs;
;; it is usually a mistake for a Lisp function to use any subroutine
;; that uses or sets the mark."
;; (declare (interactive-only t))
;; (interactive)
;; (push-mark (point))
;; (push-mark (point-max) nil t)
;; (goto-char (point-min)))
;;
(defun mark-whole-buffer ()
"Put point at beginning and mark at end of buffer.
If narrowing is in effect, only uses the accessible part of the buffer.
You probably should not use this function in Lisp programs;
it is usually a mistake for a Lisp function to use any subroutine
that uses or sets the mark."
(declare (interactive-only t))
(interactive)
(push-mark)
(push-mark (point-max) nil t)
;; This is really `point-min' in most cases, but if we're in the
;; minibuffer, this is at the end of the prompt.
(goto-char (minibuffer-prompt-end))))
(t
(error "Remove the hack that backports mark-whole-buffer when we get to Emacs 26.")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.