* Re: How to make `M-<' not set mark?
2008-10-05 12:05 How to make `M-<' not set mark? Rodolfo Medina
@ 2008-10-05 11:28 ` Rupert Swarbrick
2008-10-05 16:12 ` Rodolfo Medina
0 siblings, 1 reply; 4+ messages in thread
From: Rupert Swarbrick @ 2008-10-05 11:28 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
> Normally, the `M-<' and `M->' commands automatically set a new mark.
> How can I prevent that?
>
> Thanks for any help
> Rodolfo
Well, C-h f M-< gives:
-----
beginning-of-buffer is an interactive compiled Lisp function in `simple.el'.
It is bound to <begin>, <C-home>, M-<.
(beginning-of-buffer &optional ARG)
Move point to the beginning of the buffer; leave mark at previous position.
With C-u prefix, do not set mark at previous position.
With numeric arg N, put point N/10 of the way from the beginning.
If the buffer is narrowed, this command uses the beginning and size
of the accessible part of the buffer.
Don't use this command in Lisp programs!
(goto-char (point-min)) is faster and avoids clobbering the mark.
-----
So I'd recommend either hitting C-u beforehand, or (looking at section
21.12 of the elisp manual) do something like
(global-set-key (kbd "M-<")
(lambda () (beginning-of-buffer '(4))))
or indeed
(global-set-key (kbd "M-<")
(lambda () (goto-char (point-min))))
Rupert
[-- Attachment #2: Type: application/pgp-signature, Size: 314 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* How to make `M-<' not set mark?
@ 2008-10-05 12:05 Rodolfo Medina
2008-10-05 11:28 ` Rupert Swarbrick
0 siblings, 1 reply; 4+ messages in thread
From: Rodolfo Medina @ 2008-10-05 12:05 UTC (permalink / raw)
To: help-gnu-emacs
Normally, the `M-<' and `M->' commands automatically set a new mark. How can I
prevent that?
Thanks for any help
Rodolfo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to make `M-<' not set mark?
2008-10-05 11:28 ` Rupert Swarbrick
@ 2008-10-05 16:12 ` Rodolfo Medina
2008-10-05 17:09 ` Rupert Swarbrick
0 siblings, 1 reply; 4+ messages in thread
From: Rodolfo Medina @ 2008-10-05 16:12 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
>> Normally, the `M-<' and `M->' commands automatically set a new mark.
>> How can I prevent that?
Rupert Swarbrick <rswarbrick@gmail.com> writes:
> Well, C-h f M-< gives:
>
> [...]
>
> So I'd recommend either hitting C-u beforehand, or (looking at section
> 21.12 of the elisp manual) do something like
>
> (global-set-key (kbd "M-<")
> (lambda () (beginning-of-buffer '(4))))
>
> or indeed
>
> (global-set-key (kbd "M-<")
> (lambda () (goto-char (point-min))))
I copied the definition of `beginning-of-buffer' from the file simple.el and
commented out the part related to mark:
(defun my-beginning-of-buffer (&optional arg)
(interactive "P")
; (or (consp arg)
; (and transient-mark-mode mark-active)
; (push-mark))
(let ((size (- (point-max) (point-min))))
(goto-char (if (and arg (not (consp arg)))
(+ (point-min)
(if (> size 10000)
;; Avoid overflow for large buffer sizes!
(* (prefix-numeric-value arg)
(/ size 10))
(/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
(point-min))))
(if arg (forward-line 1)))
, then bound `M-<' to the new definition:
(global-set-key (kbd "M-<") 'my-beginning-of-buffer)
. It seems to work all right.
Rodolfo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to make `M-<' not set mark?
2008-10-05 16:12 ` Rodolfo Medina
@ 2008-10-05 17:09 ` Rupert Swarbrick
0 siblings, 0 replies; 4+ messages in thread
From: Rupert Swarbrick @ 2008-10-05 17:09 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 908 bytes --]
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
> I copied the definition of `beginning-of-buffer' from the file simple.el and
> commented out the part related to mark:
>
<SNIP>
>
> , then bound `M-<' to the new definition:
>
> (global-set-key (kbd "M-<") 'my-beginning-of-buffer)
>
>
> . It seems to work all right.
> Rodolfo
Hmm, a conceptually neater way to me would be something like:
(defun my-beginning-of-buffer (&optional arg)
(beginning-of-buffer (or arg '(4))))
and setting M-< as you do. However, this does mean that (unlike your
code), the mark is set if you use crazy prefix args to jump back 50% of
the file or whatever.
I guess the question is whether you'd prefer to have a local copy of a
core defun (which I find a bit icky) or to have the desired behaviour
with prefix argument, which I don't think you can get without completely
redefining beginning-of-buffer as you do.
Rupert
[-- Attachment #2: Type: application/pgp-signature, Size: 314 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-05 17:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-05 12:05 How to make `M-<' not set mark? Rodolfo Medina
2008-10-05 11:28 ` Rupert Swarbrick
2008-10-05 16:12 ` Rodolfo Medina
2008-10-05 17:09 ` Rupert Swarbrick
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).