Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


MELPA Stable MELPA pipeline status


You might want to read the introductory blog post.

Redefine M-< and M-> (or any key bound to beginning-of-buffer or end-of-buffer) for some modes so that point moves to meaningful locations. The real beginning and end of buffers (i.e., point-min and point-max) are still accessible by pressing the same key again.

In particular, these modes are supported:

bs-modefirst bufferlast buffer
compilation-modefirst compilation errorlast compilation error
deft-modefirst matchlast match
dired-modefirst filelast file
elfeed-search-modefirst feedlast feed
elfeed-show-modefirst body lineend of buffer
epa-key-list-modefirst keylast key
ibuffer-modefirst bufferlast buffer
magit-status-modefirst sectionlast section
magit-revision-modefirst fileend of buffer
message-modefirst body linelast line before signature
notmuch-search-modefirst threadlast thread
nroam-modeafter the titlebefore backlinks
occur-modefirst matchlast match
org-agenda-modefirst agenda itemlast agenda item
org-modefirst headingend of buffer
outline-modefirst headingend of buffer
prodigy-modefirst servicelast service
prog-modeafter initial commentsbefore final comments
recentf-dialog-modefirst most recent filelast most recent file
rg-modefirst matchlast match
vc-dir-modefirst interesting filelast interesting file

Finally, beginend does what you expect when your buffer is narrowed.


Use melpa.

You can activate beginend for all modes it supports by customizing the variable beginend-global-mode (M-x customize-variable RET beginend-global-mode RET) or by adding this line to your configuration file:


You can also decide to only activate beginend for some of its supported major modes (e.g., through beginend-dired-mode).

init.el example configuration

Vanilla Emacs init.el:

(require 'beginend)

Configuration with the popular use-package macro:

(use-package beginend 
  :ensure t
  :demand t

Cleaning up the modeline

By default, beginend adds the be lighter to the modeline.

You can use diminish.el or delight.el to turn this off for every minor mode beginend defines by looping over the beginend-modes variable. Note that you will also need to “turn off the lights” for beginend-global-mode, which is not part of this list.

If you usually diminish all minor modes, I recommend using minions.el.

In the following snippets, you can replace delight with diminish for similar results.

Adapting the vanilla Emacs init.el:

(require 'beginend)
(dolist (mode (cons 'beginend-global-mode (mapcar #'cdr beginend-modes)))
        (diminish mode))

Adapting the use-package macro configuration:

(use-package beginend 
  :ensure t
  :demand t
  (dolist (mode (cons 'beginend-global-mode (mapcar #'cdr beginend-modes)))
          (diminish mode))


At this point, newly opened supported buffers will get improved versions of M-< and M-> (or any key bound to beginning-of-buffer or end-of-buffer).

The following shows some screencasts. In each screencast, the cursor is moved to the meaningful beginning and end and to the real beginning and end.

Dired mode


Magit status mode


Message mode


Programming mode


Occur mode



Yes, please do! See CONTRIBUTING for guidelines.

Adding new modes is a matter of a few lines of code. For example, these five lines (already included) define the behavior of beginend in org-agenda-mode:

(beginend-define-mode org-agenda-mode
    (org-agenda-next-item 1))
    (org-agenda-previous-item 1)))

The first progn is responsible for moving point to the meaningful beginning of buffer. Before being executed, point is at the real beginning of the buffer (i.e., point-min). The expression (org-agenda-next-item 1) thus moves to the first agenda item. Similarly, the second progn is responsible for moving point to the meaningful end of buffer starting from real end (i.e., point-max).


See COPYING. Copyright (c) 2017-2022 Damien Cassou and Matus Goljer.