[Top][All Lists]

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

Re: Advice on troubleshooting function to "unscroll"

From: Joost Kremers
Subject: Re: Advice on troubleshooting function to "unscroll"
Date: 25 Jan 2015 21:35:46 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Will Monroe wrote:
> (defadvice scroll-up (before remember-for-unscroll
>                            activate compile)
>    "Remember where we started from, for 'unscroll'."
>    (if (not (eq last-command 'scroll-up))

Note that

    (if (not <some-test>)
         ... )

can be written as

    (unless <some-test>

if you don't have an `else' part. It's slightly more readable that way

Also, as of (I think) Emacs 24.4, defadvice is no longer the recommended
way to advise functions. There's a new package (`nadvice.el`) that
defines `advice-add`. See the Elisp manual, section "Advising functions".

> The test was just opening a lengthy file, usually an info page or an 
> existing org-mode file, pressing C-v a few times, and then using M-x 
> unscroll.  In all cases, I found that M-x unscroll would return to the 
> position just before the last C-v but not to the original position.  In 
> other words, if I pressed C-v two times and then pressed M-x unscroll, 
> in would only go back one C-v.  My intent, and that of the example in 
> the book, is to return the point the position before any C-v key 
> sequences were pressed.

Have you checked what `C-v` is bound to? In my Emacs (24.4) it's bound
to `scroll-up-command`, not to `scroll-up`. So that would defeat your if
test above.


Joost Kremers                         
Selbst in die Unterwelt dringt durch Spalten Licht

reply via email to

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