* Alt-v behavior near beginning of buffer
@ 2007-01-25 1:13 Matthew Flaschen
2007-01-25 8:47 ` Kevin Rodgers
0 siblings, 1 reply; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-25 1:13 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 413 bytes --]
I am trying to figure out how to create a new function that will scroll
up a screen if possible, or go the beginning of the buffer otherwise; I
would then bind this to M-v. Ultimately, I want to have the corollary
behavior for C-v.
I can't figure out how to test whether it is possible to scroll up/down
an entire screen. I found (goto-char (point-min/max)) , so that part
should be okay.
Matthew
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-25 1:13 Matthew Flaschen
@ 2007-01-25 8:47 ` Kevin Rodgers
2007-01-25 15:46 ` Matthew Flaschen
0 siblings, 1 reply; 13+ messages in thread
From: Kevin Rodgers @ 2007-01-25 8:47 UTC (permalink / raw)
To: help-gnu-emacs
Matthew Flaschen wrote:
> I am trying to figure out how to create a new function that will scroll
> up a screen if possible, or go the beginning of the buffer otherwise; I
> would then bind this to M-v. Ultimately, I want to have the corollary
> behavior for C-v.
>
> I can't figure out how to test whether it is possible to scroll up/down
> an entire screen. I found (goto-char (point-min/max)) , so that part
> should be okay.
(if (pos-visible-in-window-p (point-min))
(beginning-of-buffer)
(scroll-down))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-25 8:47 ` Kevin Rodgers
@ 2007-01-25 15:46 ` Matthew Flaschen
2007-01-25 15:57 ` Matthew Flaschen
0 siblings, 1 reply; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-25 15:46 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1107 bytes --]
Kevin Rodgers wrote:
> Matthew Flaschen wrote:
>> I am trying to figure out how to create a new function that will scroll
>> up a screen if possible, or go the beginning of the buffer otherwise; I
>> would then bind this to M-v. Ultimately, I want to have the corollary
>> behavior for C-v.
>>
>> I can't figure out how to test whether it is possible to scroll up/down
>> an entire screen. I found (goto-char (point-min/max)) , so that part
>> should be okay.
>
> (if (pos-visible-in-window-p (point-min))
> (beginning-of-buffer)
> (scroll-down))
>
Thanks, that was what I needed. I ended up with:
(defun power-top ()
"Scrolls up a screen if possible, or goes to the top of the buffer"
(interactive)
(if (pos-visible-in-window-p (point-min))
(goto-char (point-min))
(scroll-down)))
(defun power-bottom ()
"Scrolls up a screen if possible, or goes to the top of the buffer"
(interactive)
(if (pos-visible-in-window-p (point-max))
(goto-char (point-max))
(scroll-up)))
(global-set-key [?\M-v] 'power-top )
(global-set-key [?\C-v] 'power-bottom )
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-25 15:46 ` Matthew Flaschen
@ 2007-01-25 15:57 ` Matthew Flaschen
2007-01-26 0:25 ` Matthew Flaschen
2007-01-30 6:07 ` Kevin Rodgers
0 siblings, 2 replies; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-25 15:57 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 225 bytes --]
Matthew Flaschen wrote:
>
> (defun power-bottom ()
> "Scrolls up a screen if possible, or goes to the top of the buffer"
Doc here should be:
"Scrolls down a screen if possible, or goes to the bottom of the buffer.
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-25 15:57 ` Matthew Flaschen
@ 2007-01-26 0:25 ` Matthew Flaschen
2007-01-30 6:00 ` Kevin Rodgers
2007-01-30 6:07 ` Kevin Rodgers
1 sibling, 1 reply; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-26 0:25 UTC (permalink / raw)
Cc: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 748 bytes --]
Matthew Flaschen wrote:
> Matthew Flaschen wrote:
>> (defun power-bottom ()
>> "Scrolls up a screen if possible, or goes to the top of the buffer"
> Doc here should be:
>
> "Scrolls down a screen if possible, or goes to the bottom of the buffer.
I wanted it to go to the beginning of the line either way, so I changed
it to:
(defun power-bottom ()
"Scrolls down a screen if possible, or goes to the bottom of the buffer"
(interactive)
(if (pos-visible-in-window-p (point-max))
((lambda()
(goto-char (point-max))
(beginning-of-line)))
(scroll-up)))
That lambda syntax took me a while to grasp. Is there any easier way to
do this, short of creating a function just for the lambda?
Matthew Flaschen
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
[not found] <mailman.3548.1169687602.2155.help-gnu-emacs@gnu.org>
@ 2007-01-27 5:40 ` Eric Eide
2007-01-27 7:36 ` Matthew Flaschen
0 siblings, 1 reply; 13+ messages in thread
From: Eric Eide @ 2007-01-27 5:40 UTC (permalink / raw)
To: help-gnu-emacs
"Matthew" == Matthew Flaschen <matthew.flaschen@gatech.edu> writes:
Matthew> I am trying to figure out how to create a new function that
Matthew> will scroll up a screen if possible, or go the beginning of
Matthew> the buffer otherwise; I would then bind this to M-v.
Matthew> Ultimately, I want to have the corollary behavior for C-v.
If you want an Emacs add-on that does this (and much more), you might try:
http://www.cs.utah.edu/~eeide/emacs/scroll-in-place.el.gz
Eric.
--
-------------------------------------------------------------------------------
Eric Eide <eeide@cs.utah.edu> . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-27 5:40 ` Alt-v behavior near beginning of buffer Eric Eide
@ 2007-01-27 7:36 ` Matthew Flaschen
0 siblings, 0 replies; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-27 7:36 UTC (permalink / raw)
Cc: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 849 bytes --]
Eric Eide wrote:
> "Matthew" == Matthew Flaschen <matthew.flaschen@gatech.edu> writes:
>
> Matthew> I am trying to figure out how to create a new function that
> Matthew> will scroll up a screen if possible, or go the beginning of
> Matthew> the buffer otherwise; I would then bind this to M-v.
> Matthew> Ultimately, I want to have the corollary behavior for C-v.
>
> If you want an Emacs add-on that does this (and much more), you might try:
>
> http://www.cs.utah.edu/~eeide/emacs/scroll-in-place.el.gz
>
> Eric.
>
Sometimes I think it's impossible to do anything in emacs without
reinventing the wheel. ;) However, the package seems a bit hefty, given
that the emacs scrolling behavior (after my adjustment) doesn't really
bother me. I'll hold off installing it for now, but may do so later.
Thanks,
Matt
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-26 0:25 ` Matthew Flaschen
@ 2007-01-30 6:00 ` Kevin Rodgers
2007-01-30 15:59 ` Matthew Flaschen
0 siblings, 1 reply; 13+ messages in thread
From: Kevin Rodgers @ 2007-01-30 6:00 UTC (permalink / raw)
To: help-gnu-emacs
Matthew Flaschen wrote:
> I wanted it to go to the beginning of the line either way, so I changed
> it to:
>
> (defun power-bottom ()
> "Scrolls down a screen if possible, or goes to the bottom of the buffer"
> (interactive)
> (if (pos-visible-in-window-p (point-max))
> ((lambda()
> (goto-char (point-max))
> (beginning-of-line)))
> (scroll-up)))
>
> That lambda syntax took me a while to grasp. Is there any easier way to
> do this, short of creating a function just for the lambda?
Of course:
(progn
(goto-char (point-max))
(beginning-of-line))
A good Emacs Lisp exercise would be to allow your new command to accept
a prefix argument just like scroll-up does, and pass it to scroll-up.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-25 15:57 ` Matthew Flaschen
2007-01-26 0:25 ` Matthew Flaschen
@ 2007-01-30 6:07 ` Kevin Rodgers
2007-01-30 16:02 ` Matthew Flaschen
1 sibling, 1 reply; 13+ messages in thread
From: Kevin Rodgers @ 2007-01-30 6:07 UTC (permalink / raw)
To: help-gnu-emacs
Matthew Flaschen wrote:
> Matthew Flaschen wrote:
>> (defun power-bottom ()
>> "Scrolls up a screen if possible, or goes to the top of the buffer"
> Doc here should be:
>
> "Scrolls down a screen if possible, or goes to the bottom of the buffer.
Or to use Emacs terminology:
"Scroll text of current window upward, or move point near end of buffer.
The window text is scrolled unless the end of the buffer is visible;
otherwise point is moved to beginning of the last line of the buffer."
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-30 6:00 ` Kevin Rodgers
@ 2007-01-30 15:59 ` Matthew Flaschen
2007-01-31 5:10 ` Kevin Rodgers
0 siblings, 1 reply; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-30 15:59 UTC (permalink / raw)
Cc: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 996 bytes --]
Kevin Rodgers wrote:
> Matthew Flaschen wrote:
>> I wanted it to go to the beginning of the line either way, so I changed
>> it to:
>>
>> (defun power-bottom ()
>> "Scrolls down a screen if possible, or goes to the bottom of the buffer"
>> (interactive)
>> (if (pos-visible-in-window-p (point-max))
>> ((lambda()
>> (goto-char (point-max))
>> (beginning-of-line)))
>> (scroll-up)))
>>
>> That lambda syntax took me a while to grasp. Is there any easier way to
>> do this, short of creating a function just for the lambda?
>
> Of course:
>
> (progn
> (goto-char (point-max))
> (beginning-of-line))
Thanks, that's a bit simpler. I'd seen that command before, but forgot
it (and probably never really understood what it did).
>
> A good Emacs Lisp exercise would be to allow your new command to accept
> a prefix argument just like scroll-up does, and pass it to scroll-up.
I may do that at some point.
Matt Flaschen
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-30 6:07 ` Kevin Rodgers
@ 2007-01-30 16:02 ` Matthew Flaschen
0 siblings, 0 replies; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-30 16:02 UTC (permalink / raw)
To: emacs
[-- Attachment #1.1: Type: text/plain, Size: 629 bytes --]
Kevin Rodgers wrote:
> Matthew Flaschen wrote:
>> Matthew Flaschen wrote:
>>> (defun power-bottom ()
>>> "Scrolls up a screen if possible, or goes to the top of the buffer"
>> Doc here should be:
>>
>> "Scrolls down a screen if possible, or goes to the bottom of the buffer.
>
> Or to use Emacs terminology:
>
> "Scroll text of current window upward, or move point near end of buffer.
>
> The window text is scrolled unless the end of the buffer is visible;
> otherwise point is moved to beginning of the last line of the buffer."
>
Thanks, I've adapted this for the other function too.
Matt Flaschen
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-30 15:59 ` Matthew Flaschen
@ 2007-01-31 5:10 ` Kevin Rodgers
2007-01-31 6:29 ` Matthew Flaschen
0 siblings, 1 reply; 13+ messages in thread
From: Kevin Rodgers @ 2007-01-31 5:10 UTC (permalink / raw)
To: help-gnu-emacs
Matthew Flaschen wrote:
> Kevin Rodgers wrote:
>> (progn
>> (goto-char (point-max))
>> (beginning-of-line))
>
> Thanks, that's a bit simpler. I'd seen that command before, but forgot
> it (and probably never really understood what it did).
<pedantic>
progn is technically not a command, which is a function with an
interactive form at the beginning of its body (optionally preceded by a
doc string). progn is actually a special form, which is a primitive
function (i.e. implemented in C) whose arguments are not evaluated
before being passed to the function: instead, the special form is
responsible for evaluating them as desired.
See the "Function Type", "Primitive Function Type", "Special Forms", and
"Defining Commands" nodes of the Emacs Lisp manual.
</pedantic>
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Alt-v behavior near beginning of buffer
2007-01-31 5:10 ` Kevin Rodgers
@ 2007-01-31 6:29 ` Matthew Flaschen
0 siblings, 0 replies; 13+ messages in thread
From: Matthew Flaschen @ 2007-01-31 6:29 UTC (permalink / raw)
Cc: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 975 bytes --]
Kevin Rodgers wrote:
> Matthew Flaschen wrote:
>> Kevin Rodgers wrote:
>>> (progn
>>> (goto-char (point-max))
>>> (beginning-of-line))
>>
>> Thanks, that's a bit simpler. I'd seen that command before, but forgot
>> it (and probably never really understood what it did).
>
> <pedantic>
> progn is technically not a command, which is a function with an
> interactive form at the beginning of its body (optionally preceded by a
> doc string). progn is actually a special form, which is a primitive
> function (i.e. implemented in C) whose arguments are not evaluated
> before being passed to the function: instead, the special form is
> responsible for evaluating them as desired.
>
> See the "Function Type", "Primitive Function Type", "Special Forms", and
> "Defining Commands" nodes of the Emacs Lisp manual.
> </pedantic>
Thanks for clarifying. I'm still trying to get the feel of emacs lisp
(off and on).
Matthew Flaschen
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-01-31 6:29 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.3548.1169687602.2155.help-gnu-emacs@gnu.org>
2007-01-27 5:40 ` Alt-v behavior near beginning of buffer Eric Eide
2007-01-27 7:36 ` Matthew Flaschen
2007-01-25 1:13 Matthew Flaschen
2007-01-25 8:47 ` Kevin Rodgers
2007-01-25 15:46 ` Matthew Flaschen
2007-01-25 15:57 ` Matthew Flaschen
2007-01-26 0:25 ` Matthew Flaschen
2007-01-30 6:00 ` Kevin Rodgers
2007-01-30 15:59 ` Matthew Flaschen
2007-01-31 5:10 ` Kevin Rodgers
2007-01-31 6:29 ` Matthew Flaschen
2007-01-30 6:07 ` Kevin Rodgers
2007-01-30 16:02 ` Matthew Flaschen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.