unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Save on losing focus in Emacs
@ 2007-07-01 13:25 Sergey Pariev
  2007-07-01 14:40 ` Emilio Lopes
  0 siblings, 1 reply; 21+ messages in thread
From: Sergey Pariev @ 2007-07-01 13:25 UTC (permalink / raw)
  To: help-gnu-emacs

Hi All.

I'd like to see in Emacs one feature from IntellijIDEA I really like -
when editing files, if you switch to another window - browser of
terminal, it automatically saves file being edited - very handy when
frequently switching between apps on debugging, for example.
Googling gave me this - http://www.dribin.org/dave/blog/archives/2003/09/10/emacs/
, but snippet provided there doesn't work in my GNU Emacs 23 taken
from here
- http://peadrop.com/blog/2007/01/06/pretty-emacs/  (I'm using Ubuntu
Linux); I'm elisp newbie, but I guess code is XEmacs specific ...
Could you please suggest me how such a feature can be implemented in
GNU Emacs 23 ?

Regards, Sergey Pariev.

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

* Re: Save on losing focus in Emacs
  2007-07-01 13:25 Save on losing focus in Emacs Sergey Pariev
@ 2007-07-01 14:40 ` Emilio Lopes
  2007-07-01 17:56   ` Sergey Pariev
  0 siblings, 1 reply; 21+ messages in thread
From: Emilio Lopes @ 2007-07-01 14:40 UTC (permalink / raw)
  To: help-gnu-emacs

Sergey Pariev writes:

> I'd like to see in Emacs one feature from IntellijIDEA I really like -
> when editing files, if you switch to another window - browser of
> terminal, it automatically saves file being edited - very handy when
> frequently switching between apps on debugging, for example.

If you start "make" (or whatever you use to compile your Java source
files) from within Emacs by using the command `compile', it will
automatically ask you to save any unsaved buffers.

Alternatively you can explicitly call `save-some-buffers', usually
bound to "C-x s", before starting your build. 

-- 
Emílio C. Lopes                            Ich leb und weiß nit wie lang,
Munich, Germany                            ich stirb und weiß nit wann,
                                           ich fahr und weiß nit wohin,
                 (Martinus von Biberach)   mich wundert, dass ich fröhlich bin!

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

* Re: Save on losing focus in Emacs
  2007-07-01 14:40 ` Emilio Lopes
@ 2007-07-01 17:56   ` Sergey Pariev
  2007-07-01 20:12     ` David Kastrup
  0 siblings, 1 reply; 21+ messages in thread
From: Sergey Pariev @ 2007-07-01 17:56 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks for the answer.
Yes, I see, of course, I can type 'C-x s' all the time. But the whole
idea is to have buffers saved automagically every time I leave Emacs
and save myself from typing there keystrokes - it may look like a
small detail, but believe me, it's extremely convinient when doing,
for example, web development, when you frequently switch to browser to
check the results of your changes.

Regards, Sergey Pariev.

Emilio Lopes написав:
> Sergey Pariev writes:
>
> > I'd like to see in Emacs one feature from IntellijIDEA I really like -
> > when editing files, if you switch to another window - browser of
> > terminal, it automatically saves file being edited - very handy when
> > frequently switching between apps on debugging, for example.
>
> If you start "make" (or whatever you use to compile your Java source
> files) from within Emacs by using the command `compile', it will
> automatically ask you to save any unsaved buffers.
>
> Alternatively you can explicitly call `save-some-buffers', usually
> bound to "C-x s", before starting your build.
>
> --
> Em lio C. Lopes                            Ich leb und wei  nit wie lang,
> Munich, Germany                            ich stirb und wei  nit wann,
>                                            ich fahr und wei  nit wohin,
>                  (Martinus von Biberach)   mich wundert, dass ich fr hlich bin!

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

* Re: Save on losing focus in Emacs
  2007-07-01 17:56   ` Sergey Pariev
@ 2007-07-01 20:12     ` David Kastrup
  2007-07-01 20:53       ` Tassilo Horn
  0 siblings, 1 reply; 21+ messages in thread
From: David Kastrup @ 2007-07-01 20:12 UTC (permalink / raw)
  To: help-gnu-emacs

Sergey Pariev <spariev@gmail.com> writes:

> Thanks for the answer.
> Yes, I see, of course, I can type 'C-x s' all the time. But the whole
> idea is to have buffers saved automagically every time I leave Emacs
> and save myself from typing there keystrokes - it may look like a
> small detail, but believe me, it's extremely convinient when doing,
> for example, web development, when you frequently switch to browser to
> check the results of your changes.

Try advising the following function, or binding yourself to
switch-frame.

handle-switch-frame is an interactive built-in function in `C source code'.
It is bound to <switch-frame>.
(handle-switch-frame EVENT)

Handle a switch-frame event EVENT.
Switch-frame events are usually bound to this function.
A switch-frame event tells Emacs that the window manager has requested
that the user's events be directed to the frame mentioned in the event.
This function selects the selected window of the frame of EVENT.

If EVENT is frame object, handle it as if it were a switch-frame event
to that frame.

[back]


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Save on losing focus in Emacs
  2007-07-01 20:12     ` David Kastrup
@ 2007-07-01 20:53       ` Tassilo Horn
  2007-07-02  9:02         ` Tim X
  0 siblings, 1 reply; 21+ messages in thread
From: Tassilo Horn @ 2007-07-01 20:53 UTC (permalink / raw)
  To: help-gnu-emacs

David Kastrup <dak@gnu.org> writes:

Hi David,

> Try advising the following function, 

[...]

> handle-switch-frame is an interactive built-in function in `C source code'.
> It is bound to <switch-frame>.
> (handle-switch-frame EVENT)

I tried it, but it only works if I switch from one emacs frame to
another emacs frame.

,----[ ~/.emacs ]
| (defadvice handle-switch-frame (before save-some-buffers-advice activate)
|   "Save all file buffers if emacs looses focus."
|   (save-some-buffers t))
`----

The OP wants emacs to save all files when switching to other
applications like a browser (that's not an emacs browser in another
frame).

Any ideas?

Bye,
Tassilo
-- 
No person,  no idea, and no  religion deserves to be  illegal to insult,
not even the Church of Emacs. (Richard M. Stallman)

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

* Re: Save on losing focus in Emacs
  2007-07-01 20:53       ` Tassilo Horn
@ 2007-07-02  9:02         ` Tim X
  2007-07-02  9:41           ` Tassilo Horn
  0 siblings, 1 reply; 21+ messages in thread
From: Tim X @ 2007-07-02  9:02 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn <tassilo@member.fsf.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
> Hi David,
>
>> Try advising the following function, 
>
> [...]
>
>> handle-switch-frame is an interactive built-in function in `C source code'.
>> It is bound to <switch-frame>.
>> (handle-switch-frame EVENT)
>
> I tried it, but it only works if I switch from one emacs frame to
> another emacs frame.
>
> ,----[ ~/.emacs ]
> | (defadvice handle-switch-frame (before save-some-buffers-advice activate)
> |   "Save all file buffers if emacs looses focus."
> |   (save-some-buffers t))
> `----
>
> The OP wants emacs to save all files when switching to other
> applications like a browser (that's not an emacs browser in another
> frame).
>
> Any ideas?
>

Just some ideas off the top of my head. To what extent they are useful.....

The problem is likely that focus is handled by the window manager. Emacs knows
which of its frames is in focus, but doesn't really know about anything
happening outside and there doesn't seem to be any simple way to determine when
a frame loses focus (things seem more oriented to notification when a frame
gains focus. 

However, two functions which may be useful are visible-frame-list and
filtered-frame-list. To make use of these, I think you would dneed to use
run-with -idle-timer. Yo could possibly define a function that looks to see if
visible-frame-list returns anything. If it doesn't, then save any buffers with
unsaved changes. 

The problem with this is that if you have a big enough display, you may have
both your emacs frame and some other application both 'visible', but focus is
in the other application. In which case, this wouldn't work. 

Alternatively, you might be able to use mouse-position to determine when the
mouse is not in an emacs frame - the docs don't seem very clear on this and you
may need to experiment to see what this function actually returns if it is called
when the mouse focus is on another app. Its likely emacs will report the last
frame the mouse was focused on. 

Personally, I'd just rely on Emac's auto saving feature. As it currently
stands, files are auto-saved after a certain number of 'events' or after a
certain amount of idle time. You should be able to tweak the settings to save
things often enough that it is unlikely you will lose data and at the same
time, the saving doesn't interfere with normal work. 

HTH

Tim

P.S. I do find the OPs example a bit odd. I've used Emacs to develop with for
years and often need to switch to a browser or some other app and I've never
ever lost any work. I guess they must be using an OS like Windows, in which it
is easy/common for one app to crash and drag everything else down with it!




-- 
tcross (at) rapttech dot com dot au

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

* Re: Save on losing focus in Emacs
  2007-07-02  9:02         ` Tim X
@ 2007-07-02  9:41           ` Tassilo Horn
  2007-07-02 15:01             ` Why doesn't Emacs have a horizontal scroll bar? brianjiang
  2007-07-02 19:04             ` Save on losing focus in Emacs Sergey Pariev
  0 siblings, 2 replies; 21+ messages in thread
From: Tassilo Horn @ 2007-07-02  9:41 UTC (permalink / raw)
  To: help-gnu-emacs

Tim X <timx@nospam.dev.null> writes:

Hi Tim,

> However, two functions which may be useful are visible-frame-list and
> filtered-frame-list. To make use of these, I think you would dneed to
> use run-with -idle-timer. Yo could possibly define a function that
> looks to see if visible-frame-list returns anything. If it doesn't,
> then save any buffers with unsaved changes.

One problem might be that the timer has to run very often to save
immediately after losing focus.

> The problem with this is that if you have a big enough display, you
> may have both your emacs frame and some other application both
> 'visible', but focus is in the other application. In which case, this
> wouldn't work.

Hm, I use a tiling window manager, so most of the time all frames are
visible unless they're on another workspace.

> Alternatively, you might be able to use mouse-position to determine
> when the mouse is not in an emacs frame - the docs don't seem very
> clear on this and you may need to experiment to see what this function
> actually returns if it is called when the mouse focus is on another
> app. Its likely emacs will report the last frame the mouse was focused
> on.

I don't use a mouse frequently. Most of the time the pointer is in a
corner of the screen.

> P.S. I do find the OPs example a bit odd. I've used Emacs to develop with for
> years and often need to switch to a browser or some other app and I've never
> ever lost any work.

You got him wrong. Let's assume you edit a html-page in emacs and switch
to the browser to view you changes. But, damn, you forgot to save the
buffer, so you have to switch back to emacs, `C-x C-s' and switch back
to the browser and refresh again. If it had saved your changes
automatically when losing focus, that would not be needed.

Bye,
Tassilo
-- 
Chuck Norris sleeps with a pillow under his gun. 

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

* Why doesn't Emacs have a horizontal scroll bar?
  2007-07-02  9:41           ` Tassilo Horn
@ 2007-07-02 15:01             ` brianjiang
  2007-07-02 15:58               ` Peter Dyballa
  2007-07-02 19:04             ` Save on losing focus in Emacs Sergey Pariev
  1 sibling, 1 reply; 21+ messages in thread
From: brianjiang @ 2007-07-02 15:01 UTC (permalink / raw)
  To: help-gnu-emacs

Why doesn't Emacs have a horizontal scroll bar? 

Sometimes I have to use other editor to edit something just because
emacs has not horizontal scroll bar and it is not very convenient to do
some tasks. Is there any consideration that not having a horizontal
scroll bar for emacs?  I know XEmacs have horizontal scroll bar. Why not
introduce one for GNUEmacs?

Regards,
Brain

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-02 15:01             ` Why doesn't Emacs have a horizontal scroll bar? brianjiang
@ 2007-07-02 15:58               ` Peter Dyballa
  2007-07-02 16:25                 ` Lennart Borgman (gmail)
       [not found]                 ` <mailman.2967.1183393563.32220.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 21+ messages in thread
From: Peter Dyballa @ 2007-07-02 15:58 UTC (permalink / raw)
  To: brianjiang; +Cc: help-gnu-emacs


Am 02.07.2007 um 17:01 schrieb <brianjiang@gdnt.com.cn>:

> Why doesn't Emacs have a horizontal scroll bar?

Because text is either truncated or broken into the next line. Or am  
I missing something?

--
Greetings

   Pete

   It's not the valleys in life I dread so much as the dips.
                     -- Garfield

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-02 15:58               ` Peter Dyballa
@ 2007-07-02 16:25                 ` Lennart Borgman (gmail)
  2007-07-02 17:53                   ` Peter Dyballa
       [not found]                 ` <mailman.2967.1183393563.32220.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 21+ messages in thread
From: Lennart Borgman (gmail) @ 2007-07-02 16:25 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs

Peter Dyballa wrote:
> 
> Am 02.07.2007 um 17:01 schrieb <brianjiang@gdnt.com.cn>:
> 
>> Why doesn't Emacs have a horizontal scroll bar?
> 
> Because text is either truncated or broken into the next line. Or am I 
> missing something?


Maybe that a horizontal scroll bar would be useful when the text is 
truncated? ;-)

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
       [not found]                 ` <mailman.2967.1183393563.32220.help-gnu-emacs@gnu.org>
@ 2007-07-02 16:49                   ` Pascal Bourguignon
  2007-07-03 20:51                     ` Dieter Wilhelm
                                       ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Pascal Bourguignon @ 2007-07-02 16:49 UTC (permalink / raw)
  To: help-gnu-emacs

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:

> Peter Dyballa wrote:
>> Am 02.07.2007 um 17:01 schrieb <brianjiang@gdnt.com.cn>:
>> 
>>> Why doesn't Emacs have a horizontal scroll bar?
>> Because text is either truncated or broken into the next line. Or am
>> I missing something?
>
>
> Maybe that a horizontal scroll bar would be useful when the text is
> truncated? ;-)

But you don't need it to scroll!  Try: 

C-u 20 C-x <
C-u 20 C-x >


Here is the first form I have in by ~/.emacs:

(mapcar (lambda (f) (when (fboundp f) (funcall f -1)))
	'(scroll-bar-mode menu-bar-mode tool-bar-mode))

; yes, I've got it even before (require 'cl)



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-02 16:25                 ` Lennart Borgman (gmail)
@ 2007-07-02 17:53                   ` Peter Dyballa
  0 siblings, 0 replies; 21+ messages in thread
From: Peter Dyballa @ 2007-07-02 17:53 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Mailing List


Am 02.07.2007 um 18:25 schrieb Lennart Borgman (gmail):

> Peter Dyballa wrote:
>> Am 02.07.2007 um 17:01 schrieb <brianjiang@gdnt.com.cn>:
>>> Why doesn't Emacs have a horizontal scroll bar?
>> Because text is either truncated or broken into the next line. Or  
>> am I missing something?
>
>
> Maybe that a horizontal scroll bar would be useful when the text is  
> truncated? ;-)
>

Oh yes: then you could scroll away the point of truncation and would  
see a clear and empty line!

--
Greetings

   Pete

Without vi there is only GNU Emacs

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

* Re: Save on losing focus in Emacs
  2007-07-02  9:41           ` Tassilo Horn
  2007-07-02 15:01             ` Why doesn't Emacs have a horizontal scroll bar? brianjiang
@ 2007-07-02 19:04             ` Sergey Pariev
  1 sibling, 0 replies; 21+ messages in thread
From: Sergey Pariev @ 2007-07-02 19:04 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks to all you guys for the insightful responses. I'd like to
apologize if my example was unclear - English is not my native
language, so it could easily be.
Anyway, I'm think I'll try to setup frequent enough autosave to get
behaviour I need. The other ways looks too unpredictable, and, given
that I want it to work both at home (on Linux) and at work ( on
Windoze) :) , that's too much variables for me.

Regards, Sergey.

Tassilo Horn        :
> Tim X <timx@nospam.dev.null> writes:
>
> Hi Tim,
>
> > However, two functions which may be useful are visible-frame-list and
> > filtered-frame-list. To make use of these, I think you would dneed to
> > use run-with -idle-timer. Yo could possibly define a function that
> > looks to see if visible-frame-list returns anything. If it doesn't,
> > then save any buffers with unsaved changes.
>
> One problem might be that the timer has to run very often to save
> immediately after losing focus.
>
> > The problem with this is that if you have a big enough display, you
> > may have both your emacs frame and some other application both
> > 'visible', but focus is in the other application. In which case, this
> > wouldn't work.
>
> Hm, I use a tiling window manager, so most of the time all frames are
> visible unless they're on another workspace.
>
> > Alternatively, you might be able to use mouse-position to determine
> > when the mouse is not in an emacs frame - the docs don't seem very
> > clear on this and you may need to experiment to see what this function
> > actually returns if it is called when the mouse focus is on another
> > app. Its likely emacs will report the last frame the mouse was focused
> > on.
>
> I don't use a mouse frequently. Most of the time the pointer is in a
> corner of the screen.
>
> > P.S. I do find the OPs example a bit odd. I've used Emacs to develop with for
> > years and often need to switch to a browser or some other app and I've never
> > ever lost any work.
>
> You got him wrong. Let's assume you edit a html-page in emacs and switch
> to the browser to view you changes. But, damn, you forgot to save the
> buffer, so you have to switch back to emacs, `C-x C-s' and switch back
> to the browser and refresh again. If it had saved your changes
> automatically when losing focus, that would not be needed.
>
> Bye,
> Tassilo
> --
> Chuck Norris sleeps with a pillow under his gun.

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-02 16:49                   ` Pascal Bourguignon
@ 2007-07-03 20:51                     ` Dieter Wilhelm
       [not found]                     ` <mailman.3029.1183495887.32220.help-gnu-emacs@gnu.org>
                                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Dieter Wilhelm @ 2007-07-03 20:51 UTC (permalink / raw)
  To: Pascal Bourguignon; +Cc: help-gnu-emacs

Pascal Bourguignon <pjb@informatimago.com> writes:

> Here is the first form I have in by ~/.emacs:
>
> (mapcar (lambda (f) (when (fboundp f) (funcall f -1)))
> 	'(scroll-bar-mode menu-bar-mode tool-bar-mode))

That is very nice, thanks, I adapted it to my .emacs as well.  But is
the fboundp check not a bit superfluous with this concise list?

By the way, I'm just curious whether this might be more elegant, would
you mind doing the same with a macro definition?

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
       [not found]                     ` <mailman.3029.1183495887.32220.help-gnu-emacs@gnu.org>
@ 2007-07-03 22:16                       ` David Kastrup
  2007-07-03 22:45                         ` David Kastrup
                                           ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: David Kastrup @ 2007-07-03 22:16 UTC (permalink / raw)
  To: help-gnu-emacs

Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:

> Pascal Bourguignon <pjb@informatimago.com> writes:
>
>> Here is the first form I have in by ~/.emacs:
>>
>> (mapcar (lambda (f) (when (fboundp f) (funcall f -1)))
>> 	'(scroll-bar-mode menu-bar-mode tool-bar-mode))

(let ((h '(scroll-bar-mode menu-bar-mode tool-bar-mode)))
  (run-hook-with-args 'h -1))

> That is very nice, thanks, I adapted it to my .emacs as well.  But
> is the fboundp check not a bit superfluous with this concise list?
>
> By the way, I'm just curious whether this might be more elegant, would
> you mind doing the same with a macro definition?

A definition for the purpose of an action is never elegant.

(macrolet ((h (&rest lst) (cons 'progn
                                (mapcar (lambda (x) (list x -1)) lst))))
          (h scroll-bar-mode menu-bar-mode tool-bar-mode))


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-03 22:16                       ` David Kastrup
@ 2007-07-03 22:45                         ` David Kastrup
  2007-07-04  5:58                         ` Dieter Wilhelm
       [not found]                         ` <mailman.3044.1183528715.32220.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 21+ messages in thread
From: David Kastrup @ 2007-07-03 22:45 UTC (permalink / raw)
  To: help-gnu-emacs

David Kastrup <dak@gnu.org> writes:

> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:

>> By the way, I'm just curious whether this might be more elegant, would
>> you mind doing the same with a macro definition?
>
> A definition for the purpose of an action is never elegant.
>
> (macrolet ((h (&rest lst) (cons 'progn
>                                 (mapcar (lambda (x) (list x -1)) lst))))
>           (h scroll-bar-mode menu-bar-mode tool-bar-mode))

Perhaps more macroesque would be

(macrolet ((h (lst) `(progn ,@(mapcar (lambda (x) `(,x -1)) lst))))
          (h (scroll-bar-mode menu-bar-mode tool-bar-mode)))


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-03 22:16                       ` David Kastrup
  2007-07-03 22:45                         ` David Kastrup
@ 2007-07-04  5:58                         ` Dieter Wilhelm
       [not found]                         ` <mailman.3044.1183528715.32220.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 21+ messages in thread
From: Dieter Wilhelm @ 2007-07-04  5:58 UTC (permalink / raw)
  To: David Kastrup; +Cc: help-gnu-emacs

David Kastrup <dak@gnu.org> writes:

Hi David

> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>
>> Pascal Bourguignon <pjb@informatimago.com> writes:
>>
>>> Here is the first form I have in by ~/.emacs:
>>>
>>> (mapcar (lambda (f) (when (fboundp f) (funcall f -1)))
>>> 	'(scroll-bar-mode menu-bar-mode tool-bar-mode))
>
> (let ((h '(scroll-bar-mode menu-bar-mode tool-bar-mode)))
>   (run-hook-with-args 'h -1))

Ahh, not bad either, thanks.  Why is it necessary to provide a symbol
to the run-hook-with-args function?  Is it not possible to "overload"
functions with various arguments in lisp?

(run-hook-with-args '(scroll-bar-mode tool-bar-mode) 1)
(run-hook-with-args sroll-bar-mode 1)

>
>> That is very nice, thanks, I adapted it to my .emacs as well.  But
>> is the fboundp check not a bit superfluous with this concise list?
>>
>> By the way, I'm just curious whether this might be more elegant, would
>> you mind doing the same with a macro definition?
>
> A definition for the purpose of an action is never elegant.
>
> (macrolet ((h (&rest lst) (cons 'progn
>                                 (mapcar (lambda (x) (list x -1)) lst))))
>           (h scroll-bar-mode menu-bar-mode tool-bar-mode))

I'm sorry, I've to chew on it for a while, I'll ask/comment later.

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
       [not found]                         ` <mailman.3044.1183528715.32220.help-gnu-emacs@gnu.org>
@ 2007-07-04 17:16                           ` David Kastrup
  0 siblings, 0 replies; 21+ messages in thread
From: David Kastrup @ 2007-07-04 17:16 UTC (permalink / raw)
  To: help-gnu-emacs

Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> (let ((h '(scroll-bar-mode menu-bar-mode tool-bar-mode)))
>>   (run-hook-with-args 'h -1))
>
> Ahh, not bad either, thanks.  Why is it necessary to provide a
> symbol to the run-hook-with-args function?

Because that's what it expects.  It has to use the name to look up
local hook bindings if existing.

> Is it not possible to "overload" functions with various arguments in
> lisp?

Only when coding this explicitly.

> (run-hook-with-args '(scroll-bar-mode tool-bar-mode) 1)
> (run-hook-with-args sroll-bar-mode 1)

It is not really prepared to do this, and actually my above trickery
is an abuse of the function.

>> A definition for the purpose of an action is never elegant.

Make that "of a one-time action".

>> (macrolet ((h (&rest lst) (cons 'progn
>>                                 (mapcar (lambda (x) (list x -1)) lst))))
>>           (h scroll-bar-mode menu-bar-mode tool-bar-mode))
>
> I'm sorry, I've to chew on it for a while, I'll ask/comment later.

There is a reason why one avoids macros when they are not really
necessary.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-02 16:49                   ` Pascal Bourguignon
  2007-07-03 20:51                     ` Dieter Wilhelm
       [not found]                     ` <mailman.3029.1183495887.32220.help-gnu-emacs@gnu.org>
@ 2007-07-05  6:37                     ` Andreas Röhler
  2007-07-05  7:11                     ` Gordon Beaton
  3 siblings, 0 replies; 21+ messages in thread
From: Andreas Röhler @ 2007-07-05  6:37 UTC (permalink / raw)
  To: help-gnu-emacs

Am Montag, 2. Juli 2007 18:49 schrieb Pascal Bourguignon:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> > Peter Dyballa wrote:
> >> Am 02.07.2007 um 17:01 schrieb <brianjiang@gdnt.com.cn>:
> >>> Why doesn't Emacs have a horizontal scroll bar?
> >>
> >> Because text is either truncated or broken into the next line. Or am
> >> I missing something?
> >
> > Maybe that a horizontal scroll bar would be useful when the text is
> > truncated? ;-)
>
> But you don't need it to scroll!  Try:
>
> C-u 20 C-x <
> C-u 20 C-x >
>
>
> Here is the first form I have in by ~/.emacs:
>
> (mapcar (lambda (f) (when (fboundp f) (funcall f -1)))
> 	'(scroll-bar-mode menu-bar-mode tool-bar-mode))
>
> ; yes, I've got it even before (require 'cl)


Thanks a lot for the tip.

Searching the web with Emacs-w3m, mouse-navigation at
least is an alternative, because it jumps large
portions precisely: then a horizontal scroll would be
helpful too.

Andreas Roehler

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-02 16:49                   ` Pascal Bourguignon
                                       ` (2 preceding siblings ...)
  2007-07-05  6:37                     ` Andreas Röhler
@ 2007-07-05  7:11                     ` Gordon Beaton
  2007-07-05  7:56                       ` Peter Dyballa
  3 siblings, 1 reply; 21+ messages in thread
From: Gordon Beaton @ 2007-07-05  7:11 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, 02 Jul 2007 18:49:08 +0200, Pascal Bourguignon wrote:
> But you don't need it to scroll!  Try: 

By that reasoning, why should emacs have vertical scroll bars when you
can do M-v, C-v etc?

/gordon

-- 

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

* Re: Why doesn't Emacs have a horizontal scroll bar?
  2007-07-05  7:11                     ` Gordon Beaton
@ 2007-07-05  7:56                       ` Peter Dyballa
  0 siblings, 0 replies; 21+ messages in thread
From: Peter Dyballa @ 2007-07-05  7:56 UTC (permalink / raw)
  To: Emacs Mailing List


Am 05.07.2007 um 09:11 schrieb Gordon Beaton:

> On Mon, 02 Jul 2007 18:49:08 +0200, Pascal Bourguignon wrote:
>> But you don't need it to scroll!  Try:
>
> By that reasoning, why should emacs have vertical scroll bars when you
> can do M-v, C-v etc?
>

Because a *shell* buffer, for example, can be so large that the line  
counting in mode-line stops and then the shape of the scroll bar  
gives a hint where the cursor just might be ... And sometimes it can  
be useful to jump somewhere into the buffer by using the scroll bar  
when you know that no particularly unique text can be found there.

--
Greetings

   Pete

Never be led astray onto the path of virtue

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

end of thread, other threads:[~2007-07-05  7:56 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-01 13:25 Save on losing focus in Emacs Sergey Pariev
2007-07-01 14:40 ` Emilio Lopes
2007-07-01 17:56   ` Sergey Pariev
2007-07-01 20:12     ` David Kastrup
2007-07-01 20:53       ` Tassilo Horn
2007-07-02  9:02         ` Tim X
2007-07-02  9:41           ` Tassilo Horn
2007-07-02 15:01             ` Why doesn't Emacs have a horizontal scroll bar? brianjiang
2007-07-02 15:58               ` Peter Dyballa
2007-07-02 16:25                 ` Lennart Borgman (gmail)
2007-07-02 17:53                   ` Peter Dyballa
     [not found]                 ` <mailman.2967.1183393563.32220.help-gnu-emacs@gnu.org>
2007-07-02 16:49                   ` Pascal Bourguignon
2007-07-03 20:51                     ` Dieter Wilhelm
     [not found]                     ` <mailman.3029.1183495887.32220.help-gnu-emacs@gnu.org>
2007-07-03 22:16                       ` David Kastrup
2007-07-03 22:45                         ` David Kastrup
2007-07-04  5:58                         ` Dieter Wilhelm
     [not found]                         ` <mailman.3044.1183528715.32220.help-gnu-emacs@gnu.org>
2007-07-04 17:16                           ` David Kastrup
2007-07-05  6:37                     ` Andreas Röhler
2007-07-05  7:11                     ` Gordon Beaton
2007-07-05  7:56                       ` Peter Dyballa
2007-07-02 19:04             ` Save on losing focus in Emacs Sergey Pariev

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).