I have C-a bound to mark-whole-buffer to replicate the "select all" feature of other standard GUI editors (I also use cua-mode), as described in https://stackoverflow.com/questions/22544655/how-to-copy-select-a-whole-file-or-buffer-in-emacs

This works, but since point gets moved to the beginning of buffer it also scrolls me away from where I was working.

I would like my shortcut to mark whole buffer but not move my current screen.

My workflow would then be:

  • be somewhere in middle of buffer
  • C-a then C-c -> I now have the buffer in my clipboard and my buffer did not scroll around

How could I do that?

I tried messing with the lines in https://www.gnu.org/software/emacs/manual/html_node/eintr/Body-of-mark_002dwhole_002dbuffer.html but couldn't manage to keep buffer selected AND move the mark back to its starting position.

2 Answers 2


No, you can’t. The selection is everything between the point and the mark, so when you select everything the point must end up at either the beginning or the end of the buffer.

  • ok then is it possible to let the point go outside the buffer window?
    – John Doe
    Commented Feb 24, 2022 at 13:16
  • 1
    No, your view of the buffer always follows point so that you can always see where the text that you type in will go.
    – db48x
    Commented Feb 24, 2022 at 13:52
  • How about using the secondary selection? It would be set without moving point, but you would use the M-mouse commands to define and yank.
    – rsp
    Commented Feb 24, 2022 at 17:47
  • I am on linux, according to emacswiki.org/emacs/SecondarySelection M-clicks are intercepted by X so I can't use the shortcuts.
    – John Doe
    Commented Feb 25, 2022 at 9:53
  • Using the secondary selection is a good suggestion. As for Linux, every window manager is different. You should examine how your window manager works before deciding that you cannot use the secondary selection shortcuts. You could do this by consulting the documentation, perusing the settings to look for what keybindings and shortcuts it is currently using, or just by holding down the alt key and dragging a window. If nothing happens, then your window manager doesn’t use that shortcut and you can use it in Emacs.
    – db48x
    Commented Feb 25, 2022 at 10:12

@db48x answered your question: by definition the region in Emacs has point (the cursor position) at one of its ends.

But if your question is whether you can "select" text without having point at one end of the selection, then the answer depends on what you mean by select.

  • If you mean select as the region, then the answer is you can't (@db48x's answer).

  • But you can use the secondary selection instead of the region, as your selected text. The secondary selection has no relation to point. It need not even be visible in any window (it can be out of view).

    To make good use of the secondary selection, use library second-sel.el. It gives you easy ways to define the selection by selecting text (using keyboard or mouse), yank/paste it, set the region to it, etc.

  • If you mean highlight the text, then yes, you can do that. One way is to use library Highlight (code: highlight.el).

    With some additional libraries, such as Isearch+, you can perform some actions on such highlighted text (which, again, has nothing to do with the region).

  • I edited, hope it's clearer now. I don't care about the point, I want my current view to stay in place while i have the whole buffer selected. Looks like what I want is more related to secondary selection than to highlighting. Maybe I should give up and define binds to directly copy buffer to clipboard / delete buffer contents.
    – John Doe
    Commented Feb 24, 2022 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.