help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make `M-<' not set mark?


From: Rodolfo Medina
Subject: Re: How to make `M-<' not set mark?
Date: Sun, 05 Oct 2008 17:12:31 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.0.50 (gnu/linux)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]