all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* .emacs to keep cursor stationary when scrolling with mouse
@ 2015-05-29  2:19 JohnF
  2015-05-29  8:26 ` Damien Wyart
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: JohnF @ 2015-05-29  2:19 UTC (permalink / raw)
  To: help-gnu-emacs

I'm pretty clueless about emacs lisp, and have tried to set up
an .emacs that emulates dumb editor behavior. That works mostly
the way I want, except that when running under X and scrolling 
text with mouse (both scrolling with mouse wheel and dragging the
text bar on the window's right-hand side), the cursor still jumps around.
It remains stationary when scrolling with keyboard arrow-up/down and
keyboard page-up/down, which is what I want. But I can't get the
cursor to remain stationary when scrolling with the mouse.
How's that done???  Thanks. Here's my complete .emacs...

(setq major-mode 'text-mode)
(setq auto-mode-alist '(("." . text-mode)))
(setq make-backup-files  nil) ;;; no backup files
(setq auto-save-default  nil) ;;; no auto saving

(setq scroll-step 1)
(setq scroll-margin 0)
(setq scroll-preserve-screen-position 't) ;;; scroll without moving cursor
(setq scroll-conservatively 10000) ;;; (0 or 10000 seems same)
(setq auto-window-vscroll nil)
(setq scroll-up nil)
(setq scroll-down nil)
(setq scroll-up-aggressively nil)
(setq scroll-down-aggressively nil)
(setq next-screen-context-lines 0)
(mouse-wheel-mode 't) ;;; mouse-wheel enabled
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;;; 1 line at a time
(setq mouse-wheel-follow-mouse 't) ;;; scroll window under mouse
(setq indent-tabs-mode nil)
(setq blink-matching-paren nil)
(setq column-number-mode 't)
(setq size-indication-mode 't)

;;; open with single window
(setq inhibit-startup-screen 't)
(add-hook 'emacs-startup-hook 'delete-other-windows)

;;; initial frame width,height,position
(set-frame-width (selected-frame) 80)        ; #chars wide
(set-frame-height (selected-frame) 52)       ; #lines ling
(set-frame-position (selected-frame) 10 10 ) ; x y from upper-left

;;; insert tab character
(defun insert-tab ()
  (interactive)
  (insert "\t"))
(global-unset-key [tab])
(global-set-key (kbd "TAB") 'insert-tab)
;;; --- end-of-file ---

Thanks again,
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-29  2:19 .emacs to keep cursor stationary when scrolling with mouse JohnF
@ 2015-05-29  8:26 ` Damien Wyart
  2015-05-29 11:03   ` JohnF
  2015-05-29 19:44 ` Jorge A. Alfaro-Murillo
       [not found] ` <mailman.3927.1432928671.904.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 16+ messages in thread
From: Damien Wyart @ 2015-05-29  8:26 UTC (permalink / raw)
  To: help-gnu-emacs

* JohnF <john@please.see.sig.for.email.com> in gnu.emacs.help:
> [...] But I can't get the cursor to remain stationary when scrolling
> with the mouse. How's that done??? Thanks. Here's my complete
> .emacs... [...]

You could try to add:

(setq mouse-wheel-progressive-speed nil)

to you .emacs.

-- 
DW


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-29  8:26 ` Damien Wyart
@ 2015-05-29 11:03   ` JohnF
  2015-05-29 14:03     ` Damien Wyart
  0 siblings, 1 reply; 16+ messages in thread
From: JohnF @ 2015-05-29 11:03 UTC (permalink / raw)
  To: help-gnu-emacs

Damien Wyart <damien.wyart@free.fr> wrote:
> * JohnF <john@please.see.sig.for.email.com> in gnu.emacs.help:
>> [...] But I can't get the cursor to remain stationary when scrolling
>> with the mouse. How's that done??? Thanks. Here's my complete
>> .emacs... [...]
> 
> You could try to add:
>   (setq mouse-wheel-progressive-speed nil)
> to your .emacs.

Thanks, Damien. Added it after ...follow-mouse, i.e.,
from .emacs in original post
...
(setq mouse-wheel-follow-mouse 't) ;;; scroll window under mouse
(setq mouse-wheel-progressive-speed nil) ;;; <-- added your suggestion
...
But it had no effect. Does it do anything for you???
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-29 11:03   ` JohnF
@ 2015-05-29 14:03     ` Damien Wyart
  2015-05-30  3:25       ` JohnF
  0 siblings, 1 reply; 16+ messages in thread
From: Damien Wyart @ 2015-05-29 14:03 UTC (permalink / raw)
  To: help-gnu-emacs

> > You could try to add:
> >   (setq mouse-wheel-progressive-speed nil)
> > to your .emacs.

* JohnF <john@please.see.sig.for.email.com> in gnu.emacs.help:
> Thanks, Damien. Added it after ...follow-mouse, i.e.,
> from .emacs in original post
> ...
> (setq mouse-wheel-follow-mouse 't) ;;; scroll window under mouse
> (setq mouse-wheel-progressive-speed nil) ;;; <-- added your suggestion
> ...
> But it had no effect. Does it do anything for you???

In fact, I did not try it myself, but borrowed it from here:

http://www.emacswiki.org/emacs/SmoothScrolling
http://stackoverflow.com/questions/445873/how-can-i-make-emacs-mouse-scrolling-slower-and-smoother

Your .emacs looked correct, and I have read here or there that
mouse-wheel-progressive-speed did help in some cases, but maybe there
has been a misunderstanding on what you would like exactly.

Here is some further reading on this topic and closely related ones;
could you tell us if some of these solutions work for you, and if not,
what you would like precisely?

http://elpa.gnu.org/packages/scroll-restore.html
http://stackoverflow.com/questions/10348473/emacs-mouse-wheel-scroll-preserve-buffer-position
http://stackoverflow.com/questions/9616623/ctrl-up-down-style-scrolling-in-emacs/9620883#9620883
http://stackoverflow.com/questions/8993183/emacs-scroll-buffer-not-point
http://superuser.com/questions/527356/dont-change-the-cursor-position-when-scrolling-in-emacs
http://stackoverflow.com/questions/15895313/let-emacs-move-the-cursor-off-screen
http://emacs.stackexchange.com/questions/61/let-emacs-move-the-cursor-off-screen


Thanks,

-- 
DW


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-29  2:19 .emacs to keep cursor stationary when scrolling with mouse JohnF
  2015-05-29  8:26 ` Damien Wyart
@ 2015-05-29 19:44 ` Jorge A. Alfaro-Murillo
       [not found] ` <mailman.3927.1432928671.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 16+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-05-29 19:44 UTC (permalink / raw)
  To: help-gnu-emacs

JohnF writes:

> I'm pretty clueless about emacs lisp, and have tried to set up 
> an .emacs that emulates dumb editor behavior. That works mostly 
> the way I want, except that when running under X and scrolling 
> text with mouse (both scrolling with mouse wheel and dragging 
> the text bar on the window's right-hand side), the cursor still 
> jumps around.  It remains stationary when scrolling with 
> keyboard arrow-up/down and keyboard page-up/down, which is what 
> I want. But I can't get the cursor to remain stationary when 
> scrolling with the mouse.  How's that done??

I think that what you want is to not see the point (you call it 
cursor) in your screen and to keep the point always fixed. I know 
that is standard "modern" editor behavior, but why would you want 
that? In those editors when you scroll, the point remains where it 
was and when you type you miss what you were seeing because the 
screen goes back to where it was before you scrolled. If you want 
to edit the buffer in a different place that is irritating. Now if 
what you want is to browse the buffer in a different place you can 
do way better: split the window (C-x 2 or C-x 3) and scroll on the 
other one. Or if you do not want to split the window then push the 
mark (C-<space> C-<space>) browse what you want and then jump the 
mark (C-u C-<space>) that will get you to where you were before.

This also goes hand in hand with using the mark and the region, 
which is an integral part of emacs. Moving the point with the 
scroll is what you would expect if you are selecting a region.

Best,
-- 
Jorge.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-29 14:03     ` Damien Wyart
@ 2015-05-30  3:25       ` JohnF
  2015-05-30  9:45         ` Damien Wyart
  0 siblings, 1 reply; 16+ messages in thread
From: JohnF @ 2015-05-30  3:25 UTC (permalink / raw)
  To: help-gnu-emacs

Damien Wyart <damien.wyart@free.fr> wrote:
>> > You could try to add:
>> >   (setq mouse-wheel-progressive-speed nil)
>> > to your .emacs.
> 
> * JohnF <john@please.see.sig.for.email.com> in gnu.emacs.help:
>> Thanks, Damien. Added it after ...follow-mouse, i.e.,
>> from .emacs in original post
>> ...
>> (setq mouse-wheel-follow-mouse 't) ;;; scroll window under mouse
>> (setq mouse-wheel-progressive-speed nil) ;;; <-- added your suggestion
>> ...
>> But it had no effect. Does it do anything for you???
> 
> In fact, I did not try it myself, but borrowed it from here:
> 
> http://www.emacswiki.org/emacs/SmoothScrolling
> http://stackoverflow.com/questions/445873/how-can-i-make-emacs-mouse-scrolling-slower-and-smoother

Thanks again, Damien...

> Your .emacs looked correct,

Full disclosure: not really "mine", but cobbled together from
numerous suggestions I got from this ng and other emacs forums.

> and I have read here or there that
> mouse-wheel-progressive-speed did help in some cases, but maybe there
> has been a misunderstanding on what you would like exactly.
> 
> Here is some further reading on this topic and closely related ones;
> could you tell us if some of these solutions work for you, and if not,
> what you would like precisely?

Thanks for additional references below. The one labelled
   emacs-scroll-buffer-not-point
sounds like what I want, but it seems to address keyboard scrolling,
which is already handled. Instead, the one labelled
   emacs-mouse-wheel-scroll-preserve-buffer-position
seems to actually address my problem (though "preserve-buffer-position"
when scrolling sounds to me like an oxymoron). And very unfortunately,
the posted answer after the op describes his (and what sounds
like my) request is...
   "You can't." ...
which pretty succinctly (if correct) sums it up.

If I'm not precisely describing my request, then you can use my
.emacs and watch the point as you keyboard-scroll through your buffer.
The point (I apparently incorrectly said "cursor" -- I mean the
on-screen, often blinking, symbol that indicates where text
will be inserted when you start typing) should remain stationary
in the window when you page-up/down and when you scroll text.
When you arrow-up/down, the point should move one line up/down
at a time, without scrolling text. When the point nears the top/bottom
of the window, it >>shouldn't<< jump back towards center.
Instead, it should just stay at the top/bottom row,
and start scrolling text one line at a time.
   This is what it does with keyboard. Mouse wheel and drag bar
always scroll text, but point gets dragged along with the scrolling
text, and jumps back towards center when it nears window top/bottom.
Instead, I'd like point to just remain stationary on screen, as
yexy scrolls "underneath" it.
   The one okay exception is when the point starts on some row,column,
and then a text line that scrolls underneath it is shorter than the
original column number. Then point stays on its row, but column jumps
to end-of-(that-)line. But later, when a sufficiently long text line
scrolls underneath point, it jumps back to original column.
   Very lengthy description above -- simpler to just try it out,
whereby described behaviour is obvious.

> http://elpa.gnu.org/packages/scroll-restore.html
> http://stackoverflow.com/questions/10348473/emacs-mouse-wheel-scroll-preserve-buffer-position
> http://stackoverflow.com/questions/9616623/ctrl-up-down-style-scrolling-in-emacs/9620883#9620883
> http://stackoverflow.com/questions/8993183/emacs-scroll-buffer-not-point
> http://superuser.com/questions/527356/dont-change-the-cursor-position-when-scrolling-in-emacs
> http://stackoverflow.com/questions/15895313/let-emacs-move-the-cursor-off-screen
> http://emacs.stackexchange.com/questions/61/let-emacs-move-the-cursor-off-screen

-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
       [not found] ` <mailman.3927.1432928671.904.help-gnu-emacs@gnu.org>
@ 2015-05-30  3:43   ` JohnF
  2015-05-30  6:26     ` tomas
                       ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: JohnF @ 2015-05-30  3:43 UTC (permalink / raw)
  To: help-gnu-emacs

Jorge A. Alfaro-Murillo <jorge.alfaro-murillo@yale.edu> wrote:
> JohnF writes:
> 
>> I'm pretty clueless about emacs lisp, and have tried to set up 
>> an .emacs that emulates dumb editor behavior. That works mostly 
>> the way I want, except that when running under X and scrolling 
>> text with mouse (both scrolling with mouse wheel and dragging 
>> the text bar on the window's right-hand side), the cursor still 
>> jumps around.  It remains stationary when scrolling with 
>> keyboard arrow-up/down and keyboard page-up/down, which is what 
>> I want. But I can't get the cursor to remain stationary when 
>> scrolling with the mouse.  How's that done??
> 
> I think that what you want is to not see the point (you call it 
> cursor) in your screen and to keep the point always fixed.

Thanks for terminology correction. Well, I do want to see the point,
but, yes, very definitely, I want it to stay fixed when text scrolls.
That is, keboard page up/down should scroll text and not move point.
Ditto for mouse wheel scrolling and for mouse drag bar.
My .emacs works fine for keyboard page up/down, but not for mouse.
   For keyboard arrow up/down, point should (of course) move one row,
but shouldn't jump back towards center when it nears window top/bottom.
And my .emacs already works for that, too. So no problem there.
Just with mouse.

> I know 
> that is standard "modern" editor behavior, but why would you want 
> that?

That's just my preference. Yours is apparently different, which
is okay by me. I can no more "justify" my own editor preference than
I can justify my favorite flavor ice cream (mocha almond crunch).
The very first line of the gnu emacs page
   http://www.gnu.org/software/emacs/
says
   "GNU Emacs is an extensible, customizable text editor..."
which sounds to me like they're very intentionally acknowledging
the importance of accommodating different preferences for different
people, rather than establishing their own personal preferences
(whatever those happen to be) as the standard.

> In those editors when you scroll, the point remains where it 
> was and when you type you miss what you were seeing because the 
> screen goes back to where it was before you scrolled. If you want 
> to edit the buffer in a different place that is irritating. Now if 
> what you want is to browse the buffer in a different place you can 
> do way better: split the window (C-x 2 or C-x 3) and scroll on the 
> other one. Or if you do not want to split the window then push the 
> mark (C-<space> C-<space>) browse what you want and then jump the 
> mark (C-u C-<space>) that will get you to where you were before.
> 
> This also goes hand in hand with using the mark and the region, 
> which is an integral part of emacs. Moving the point with the 
> scroll is what you would expect if you are selecting a region.
> 
> Best,

-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-30  3:43   ` JohnF
@ 2015-05-30  6:26     ` tomas
       [not found]     ` <mailman.3945.1432967181.904.help-gnu-emacs@gnu.org>
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: tomas @ 2015-05-30  6:26 UTC (permalink / raw)
  To: JohnF; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, May 30, 2015 at 03:43:21AM +0000, JohnF wrote:

[...]

> Thanks for terminology correction. Well, I do want to see the point,
> but, yes, very definitely, I want it to stay fixed when text scrolls.
                                          ^^^^^^^^^^

Just one remark, perhaps to ease communication. When you say "stay fixed",
you mean *relative to the window* and not *relative to the buffer* (in
other words, to the underlying text), right?

It took me a while to realize that. That's because the mental model of
an Emacs person seems to be more: the buffer (i.e. the "text") is fixed,
and point (i.e. the cursor) and window (i.e. the viewport, through which
you look at the text), both move relative to it.

Seen from that perspective, you want to "move" point along with "window",
right?

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlVpWAAACgkQBcgs9XrR2kazTQCggFuuFbUZGoxNQxMwPbjcA7aL
Rl4An1ifFuLMlfc1yUR9aEIqBeNupRky
=Js0B
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
       [not found]     ` <mailman.3945.1432967181.904.help-gnu-emacs@gnu.org>
@ 2015-05-30  7:48       ` JohnF
  2015-05-30 13:04         ` tomas
       [not found]         ` <mailman.3970.1432991100.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 16+ messages in thread
From: JohnF @ 2015-05-30  7:48 UTC (permalink / raw)
  To: help-gnu-emacs

tomas@tuxteam.de wrote:
> On Sat, May 30, 2015 at 03:43:21AM +0000, JohnF wrote:
> [...]
>> Thanks for terminology correction. Well, I do want to see the point,
>> but, yes, very definitely, I want it to stay fixed when text scrolls.
> 
> Just one remark, perhaps to ease communication. When you say "stay fixed",
> you mean *relative to the window* and not *relative to the buffer* (in
> other words, to the underlying text), right?

Right. When scrolling text with keyboard page up/down. And that works now.
But when scrolling text with mouse wheel, or by dragging text bar,
I also want it fixed relative to window, and that doesn't work.
   With keyboard arrow up/down, then it should move one row up/down
relative to window, until it eventually reaches top/bottom of window.
Then text should begin scrolling one line up/down, with cursor remaining
stationary at the very top/bottom of window. And that works now, too.

> It took me a while to realize that. That's because the mental model of
> an Emacs person seems to be more: the buffer (i.e. the "text") is fixed,
> and point (i.e. the cursor) and window (i.e. the viewport, through which
> you look at the text), both move relative to it.
> 
> Seen from that perspective, you want to "move" point along with "window",
> right?
> regards
> t

Maybe, maybe not -- what's a "window"??? I meant the physical screen
real estate, what emacs maybe calls the "frame", as in, e.g.,
  (set-frame-width (selected-frame) 80)        ; #cols wide
  (set-frame-height (selected-frame) 52)       ; #rows high
Relative to that, I want the point stationary when text scrolls.
Now, if you mean the "window of the text buffer" displayed in
the frame, which changes as text scrolls, then I guess I could agree
that the point "moves" relative to that. But it seems an odd way
to phrase things...

...Maybe that's just the "mental model" you mentioned above,
for emacs relative to people (me) accustomed to other editors.
An anthropologist could maybe have a good time with that.
How does
  "Ethnocentrism as exhibited by different editor communities"
sound as the title for an article submitted to the American Journal
of Anthropology (or wherever)? :)
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-30  3:25       ` JohnF
@ 2015-05-30  9:45         ` Damien Wyart
  2015-05-31  4:03           ` JohnF
  0 siblings, 1 reply; 16+ messages in thread
From: Damien Wyart @ 2015-05-30  9:45 UTC (permalink / raw)
  To: help-gnu-emacs

> [...] This is what it does with keyboard. Mouse wheel and drag bar
> always scroll text, but point gets dragged along with the scrolling
> text, and jumps back towards center when it nears window top/bottom.
> Instead, I'd like point to just remain stationary on screen, as yexy
> scrolls "underneath" it.

I could get what you want for the wheel by using this:

(global-set-key (kbd "<mouse-4>") 'scroll-down-command)
(global-set-key (kbd "<mouse-5>") 'scroll-up-command)

Can you confirm this is OK?

About the scrollbar, I do not use it myself (many users of emacs use
"(scroll-bar-mode -1)" in their .emacs and only use keyboard and mouse
wheel), but looking at the code this is more difficult to get the exact
behavior you want. When testing, this seems most of the time to do what
you want, but a few jumps apear from time to time, depending on the
content of the buffer.

-- 
DW


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-30  7:48       ` JohnF
@ 2015-05-30 13:04         ` tomas
       [not found]         ` <mailman.3970.1432991100.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 16+ messages in thread
From: tomas @ 2015-05-30 13:04 UTC (permalink / raw)
  To: JohnF; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, May 30, 2015 at 07:48:34AM +0000, JohnF wrote:
> tomas@tuxteam.de wrote:

[...]

> > Just one remark, perhaps to ease communication. When you say "stay fixed",
> > you mean *relative to the window* and not *relative to the buffer* (in
> > other words, to the underlying text), right?
> 
> Right. When scrolling text with keyboard page up/down. And that works now.

[...]

> > It took me a while to realize that [...]
> > Seen from that perspective, you want to "move" point along with "window",

[...]

> Maybe, maybe not -- what's a "window"??? I meant the physical screen
> real estate, what emacs maybe calls the "frame", as in, e.g.,
>   (set-frame-width (selected-frame) 80)        ; #cols wide
>   (set-frame-height (selected-frame) 52)       ; #rows high

"Window" in Emacs terminology: the pane you are looking through to see
the content of the buffer. A "frame" can contain several windows. Concerning
your wish, it doesn't make much difference, because the relations between
window and frame don't change while scrolling (I'd hope ;-)

> Relative to that, I want the point stationary when text scrolls.
> Now, if you mean the "window of the text buffer" displayed in
> the frame, which changes as text scrolls, then I guess I could agree
> that the point "moves" relative to that. But it seems an odd way
> to phrase things...

Yes, that's why I pointed it out as soon as I noticed. I don't have
a direct solution to your problem (but there's another answer which
looks good), but I thought I could help bridging the sematic gap.

> ...Maybe that's just the "mental model" you mentioned above,
> for emacs relative to people (me) accustomed to other editors.
> An anthropologist could maybe have a good time with that.
> How does
>   "Ethnocentrism as exhibited by different editor communities"
> sound as the title for an article submitted to the American Journal
> of Anthropology (or wherever)? :)

:-)

But actually, this is one of the difficulties in getting up to speed with
Emacs: it's a toolset with a long history, and thus with a rich and
deeply ingrained culture which, to beginners poses a hurdle. Sometimes
things "you know" are called in strange ways, sometimes "you do" things
differently. Of course, you can customize (nearly) everything to your
liking, but sometimes it's difficult to express what you want in a
way that the Emacs tribe understands it.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlVptXUACgkQBcgs9XrR2kbH1gCeMc4vpqsoBdndDYhUY6iMDCqL
W3kAoICwfwOSRnxs0BfdSlTiXKl2sG3n
=8f4G
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-30  3:43   ` JohnF
  2015-05-30  6:26     ` tomas
       [not found]     ` <mailman.3945.1432967181.904.help-gnu-emacs@gnu.org>
@ 2015-05-31  1:18     ` Jorge A. Alfaro-Murillo
       [not found]     ` <mailman.4015.1433035116.904.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 16+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-05-31  1:18 UTC (permalink / raw)
  To: help-gnu-emacs

JohnF writes: 
 
> Thanks for terminology correction. Well, I do want to see the 
> point, but, yes, very definitely, I want it to stay fixed when 
> text scrolls.  That is, keboard page up/down should scroll text 
> and not move point.  Ditto for mouse wheel scrolling and for 
> mouse drag bar. 
 
It is like that by default, except when the point gets out of 
view. I have never seen any mode that doesn't show the point in a 
window, which is basically what you need if I understand 
correctly, if someone knows about a mode that behaves like that it 
might be a good start to figure out how to do it. 
 
>  My .emacs works fine for keyboard page up/down, but not for 
> mouse. For keyboard arrow up/down, point should (of course) move 
> one row, but shouldn't jump back towards center when it nears 
> window top/bottom.  And my .emacs already works for that, too. 
> So no problem there. Just with mouse. 
> 
>> I know that is standard "modern" editor behavior, but why would 
>> you want that? 
> 
> That's just my preference. Yours is apparently different, which 
> is okay by me. I can no more "justify" my own editor preference 
> than I can justify my favorite flavor ice cream (mocha almond 
> crunch).  The very first line of the gnu emacs page 
>    http://www.gnu.org/software/emacs/ 
> says 
>    "GNU Emacs is an extensible, customizable text editor..." 
> which sounds to me like they're very intentionally acknowledging 
> the importance of accommodating different preferences for 
> different people, rather than establishing their own personal 
> preferences (whatever those happen to be) as the standard. 
 
"It is your preference" is another way to say that you want it 
that way, I was just asking why, to see if there was another way 
to do what you want, for example, if it is to go to where you were 
before, there are better ways: pushing the mark, adding the point 
to the register, bookmarks, multiple windows and winner-mode, etc. 
That is why I wanted to know, I am not trying to establish my 
personal preferences, if I would be trying to establish my 
preferences I would have asked why do you need to use the mouse in 
the first place.

It just feels like the reason you want that is that you are used to that
behavior with other editors. You can certainly tweak emacs to do what
you want, but it will require quite a lot of effort and re-writing basic
functions of movement and display of the window, plus quite a bit of
knowledge of elisp. I just wanted to tell you that the fact that the
point moves with scrolling when it gets out of sight was one of the
things that striked me as a strange behavior when I started using emacs
a couple of years ago, but once I understood better how the region and
the mark work, that behavior made sense, especially when the region is
active.

-- 
Jorge.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
  2015-05-30  9:45         ` Damien Wyart
@ 2015-05-31  4:03           ` JohnF
  0 siblings, 0 replies; 16+ messages in thread
From: JohnF @ 2015-05-31  4:03 UTC (permalink / raw)
  To: help-gnu-emacs

Damien Wyart <damien.wyart@free.fr> wrote:
>> [...] This is what it does with keyboard. Mouse wheel and drag bar
>> always scroll text, but point gets dragged along with the scrolling
>> text, and jumps back towards center when it nears window top/bottom.
>> Instead, I'd like point to just remain stationary on screen, as yexy
>> scrolls "underneath" it.
> 
> I could get what you want for the wheel by using this:
>    (global-set-key (kbd "<mouse-4>") 'scroll-down-command)
>    (global-set-key (kbd "<mouse-5>") 'scroll-up-command)
> Can you confirm this is OK?

Absolutely confirmed! Thanks Damien, works like a charm.
I guess the guy who replied "You can't..." to one of the
stackoverflow questions you referred me to earlier was wrong.
Looks like "You can". And now "I can", too :)  Thanks.
I guess you could post this solution there, though it's
maybe a bit late for that op.

> About the scrollbar, I do not use it myself (many users of emacs use
> "(scroll-bar-mode -1)" in their .emacs and only use keyboard and mouse
> wheel),

Yeah, no problem. I use the scrollbar mostly for large moves within
the buffer, where M->,< don't get close. The wheel is way more
important to me. I'd have mentioned that if it had occurred to
me that it might make a difference.

> but looking at the code this is more difficult to get the exact
> behavior you want.

Thanks again for your time and effort looking at it.

> When testing, this seems most of the time to do what
> you want, but a few jumps apear from time to time, depending on the
> content of the buffer.

It's perfect. Those jumps occur when the point starts at a column
beyond the end-of-line for text passing underneath it as you scroll.
Then it jumps left to the end of that line, and jumps back to the
original column when text passing underneath it is again long enough.
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
       [not found]         ` <mailman.3970.1432991100.904.help-gnu-emacs@gnu.org>
@ 2015-05-31  4:34           ` JohnF
       [not found]           ` <<mke31e$k7h$1@reader1.panix.com>
  1 sibling, 0 replies; 16+ messages in thread
From: JohnF @ 2015-05-31  4:34 UTC (permalink / raw)
  To: help-gnu-emacs

tomas@tuxteam.de wrote:
> On Sat, May 30, 2015 at 07:48:34AM +0000, JohnF wrote:
>> tomas@tuxteam.de wrote:
> [...]
>> > Just one remark, perhaps to ease communication. When you say "stay fixed",
>> > you mean *relative to the window* and not *relative to the buffer* (in
>> > other words, to the underlying text), right?
>> 
>> Right. When scrolling text with keyboard page up/down. And that works now.
> [...]
> 
>> > It took me a while to realize that [...]
>> > Seen from that perspective, you want to "move" point along with "window",
> [...]
> 
>> Maybe, maybe not -- what's a "window"??? I meant the physical screen
>> real estate, what emacs maybe calls the "frame", as in, e.g.,
>>   (set-frame-width (selected-frame) 80)        ; #cols wide
>>   (set-frame-height (selected-frame) 52)       ; #rows high
> 
> "Window" in Emacs terminology: the pane you are looking through to see
> the content of the buffer. A "frame" can contain several windows.

Right... when I press  C-x 2  the 80x52 frame remains the same size,
but now contains two smaller windows. Thanks for the additional
terminology correction. Maybe I should google an "emacs glossary" page :)

> Concerning
> your wish, it doesn't make much difference, because the relations between
> window and frame don't change while scrolling (I'd hope ;-)
> 
>> Relative to that, I want the point stationary when text scrolls.
>> Now, if you mean the "window of the text buffer" displayed in
>> the frame, which changes as text scrolls, then I guess I could agree
>> that the point "moves" relative to that. But it seems an odd way
>> to phrase things...
> 
> Yes, that's why I pointed it out as soon as I noticed. I don't have
> a direct solution to your problem (but there's another answer which
> looks good), but I thought I could help bridging the sematic gap.

Yes, thanks, and as replied to Damien, his solution indeed works great!

>> ...Maybe that's just the "mental model" you mentioned above,
>> for emacs relative to people (me) accustomed to other editors.
>> An anthropologist could maybe have a good time with that.
>> How does
>>   "Ethnocentrism as exhibited by different editor communities"
>> sound as the title for an article submitted to the American Journal
>> of Anthropology (or wherever)? :)
> 
> :-)
> 
> But actually, this is one of the difficulties in getting up to speed with
> Emacs: it's a toolset with a long history, and thus with a rich and
> deeply ingrained culture which, to beginners poses a hurdle. Sometimes
> things "you know" are called in strange ways, sometimes "you do" things
> differently. Of course, you can customize (nearly) everything to your
> liking, but sometimes it's difficult to express what you want in a
> way that the Emacs tribe understands it.
> Regards
> tom?s

I've found the culture/tribe very helpful, indeed (to wit, this thread).
I was basically just looking for an .emacs that turns it into a
dumb editor: no syntax highlighting, no smart tabs, no blinking
on matching (),{},etc, no nothing. But such an .emacs turned out harder
than I'd have thought. Took me lots of googling, which turned up some
half-dumb-but-not-dumb-enough .emacs, and then lots of questions
to get to the dumb-enough stage. The .emacs I posted at the top
of this thread was the end result of that. And I think Damien's
additional suggestion above now completes the job.
Thanks again, guys,
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: .emacs to keep cursor stationary when scrolling with mouse
       [not found]     ` <mailman.4015.1433035116.904.help-gnu-emacs@gnu.org>
@ 2015-05-31  5:04       ` JohnF
  0 siblings, 0 replies; 16+ messages in thread
From: JohnF @ 2015-05-31  5:04 UTC (permalink / raw)
  To: help-gnu-emacs

Jorge A. Alfaro-Murillo <jorge.alfaro-murillo@yale.edu> wrote:
> JohnF writes: 
> 
>> Thanks for terminology correction. Well, I do want to see the 
>> point, but, yes, very definitely, I want it to stay fixed when 
>> text scrolls.  That is, keboard page up/down should scroll text 
>> and not move point.  Ditto for mouse wheel scrolling and for 
>> mouse drag bar. 
> 
> It is like that by default,
   No, i.e., by "point fixed" I mean "fixed position on screen".
   Default -- at least for me -- is that it stays "fixed" on the
   same buffer character, which means that as the character scrolls
   up or down the point moves up or down with it.
> except when the point gets out of view.
   Right, when point gets near top or bottom, it jumps back towards
   center and then stays on a new buffer character until it jumps again.
      Of course, if point stays fixed on screen, as I'd prefer,
   it never needs to jump anyway, so jumping becomes a moot "point" :)

> I have never seen any mode that doesn't show the point in a 
> window, which is basically what you need if I understand 
> correctly,

I do want to see the point, and hadn't realized I'd said anything
that might be interpreted as not wanting to see the point at all.
It's point movement when text scrolls that I was asking about.

> if someone knows about a mode that behaves like that it 
> might be a good start to figure out how to do it. 
> 
>>  My .emacs works fine for keyboard page up/down, but not for 
>> mouse. For keyboard arrow up/down, point should (of course) move 
>> one row, but shouldn't jump back towards center when it nears 
>> window top/bottom.  And my .emacs already works for that, too. 
>> So no problem there. Just with mouse. 
>> 
>>> I know that is standard "modern" editor behavior, but why would 
>>> you want that? 
>> 
>> That's just my preference. Yours is apparently different, which 
>> is okay by me. I can no more "justify" my own editor preference 
>> than I can justify my favorite flavor ice cream (mocha almond 
>> crunch).  The very first line of the gnu emacs page 
>>    http://www.gnu.org/software/emacs/ 
>> says 
>>    "GNU Emacs is an extensible, customizable text editor..." 
>> which sounds to me like they're very intentionally acknowledging 
>> the importance of accommodating different preferences for 
>> different people, rather than establishing their own personal 
>> preferences (whatever those happen to be) as the standard. 
> 
> "It is your preference" is another way to say that you want it 
> that way, I was just asking why, to see if there was another way 
> to do what you want, for example, if it is to go to where you were 
> before,

No, I don't want to "go where I was before", if by that you mean the point
should go back to the same buffer character it was on before scrolling.
Maybe you misunderstood my wording in some way, and that misunderstanding
made you think my preference was unusual. If the point stays fixed
on screen, then it's on different buffer characters as text scrolls
"underneath" it.

> there are better ways: pushing the mark, adding the point 
> to the register, bookmarks, multiple windows and winner-mode, etc. 
> That is why I wanted to know, I am not trying to establish my 
> personal preferences, if I would be trying to establish my 
> preferences I would have asked why do you need to use the mouse in 
> the first place.
> 
> It just feels like the reason you want that is that you are used to that
> behavior with other editors. You can certainly tweak emacs to do what
> you want, but it will require quite a lot of effort and re-writing basic
> functions of movement and display of the window, plus quite a bit of
> knowledge of elisp.

Not really lots of effort... the .emacs I posted originally,
now along with Damien's additional suggestion, works exactly like I want.

> I just wanted to tell you that the fact that the
> point moves with scrolling when it gets out of sight was one of the
> things that striked me as a strange behavior when I started using emacs
> a couple of years ago, but once I understood better how the region and
> the mark work, that behavior made sense, especially when the region is
> active.

-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: .emacs to keep cursor stationary when scrolling with mouse
       [not found]           ` <<mke31e$k7h$1@reader1.panix.com>
@ 2015-05-31 13:20             ` Drew Adams
  0 siblings, 0 replies; 16+ messages in thread
From: Drew Adams @ 2015-05-31 13:20 UTC (permalink / raw)
  To: JohnF, help-gnu-emacs

> > "Window" in Emacs terminology: the pane you are looking through to
> > see the content of the buffer. A "frame" can contain several windows.
> 
> Right... when I press  C-x 2  the 80x52 frame remains the same size,
> but now contains two smaller windows. Thanks for the additional
> terminology correction. Maybe I should google an "emacs glossary"
> page :)

Yes, indeed.  http://lmgtfy.com/?q=emacs+glossary

The first two hits should be exactly what you want here: the
glossaries in the Emacs manual and on Emacs Wiki.

And the manual and the wiki are generally the first two, or two of
the first three, places to look for general information about Emacs.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-05-31 13:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29  2:19 .emacs to keep cursor stationary when scrolling with mouse JohnF
2015-05-29  8:26 ` Damien Wyart
2015-05-29 11:03   ` JohnF
2015-05-29 14:03     ` Damien Wyart
2015-05-30  3:25       ` JohnF
2015-05-30  9:45         ` Damien Wyart
2015-05-31  4:03           ` JohnF
2015-05-29 19:44 ` Jorge A. Alfaro-Murillo
     [not found] ` <mailman.3927.1432928671.904.help-gnu-emacs@gnu.org>
2015-05-30  3:43   ` JohnF
2015-05-30  6:26     ` tomas
     [not found]     ` <mailman.3945.1432967181.904.help-gnu-emacs@gnu.org>
2015-05-30  7:48       ` JohnF
2015-05-30 13:04         ` tomas
     [not found]         ` <mailman.3970.1432991100.904.help-gnu-emacs@gnu.org>
2015-05-31  4:34           ` JohnF
     [not found]           ` <<mke31e$k7h$1@reader1.panix.com>
2015-05-31 13:20             ` Drew Adams
2015-05-31  1:18     ` Jorge A. Alfaro-Murillo
     [not found]     ` <mailman.4015.1433035116.904.help-gnu-emacs@gnu.org>
2015-05-31  5:04       ` JohnF

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.