unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New global bindings
@ 2008-06-03 15:56 Stefan Monnier
  2008-06-03 16:13 ` Miles Bader
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Stefan Monnier @ 2008-06-03 15:56 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel


I have some problems with the new global bindings for C--, C-=, and C-+:
1- they're not mentioned in etc/NEWS (it seems none of the face-remap
    feature is mentioned there).
2- (control -) was used for negative prefix arguments, so this is
    a significant change for oldtimers.
3- these are very short key-bindings for a feature that does not seem to
   require them: you're unlikely to want to do it that frequently.

Point nb 1 is easy to fix, maybe I can live with nb 3, but nb 2 seems to
be more problematic.  So I think we need to find some other key-bindings
for that.  I think a prefix key followed by +, -, and = (repeatable like
C-x e e e e e, maybe even allowing switching between + and -) is the
best choice.


        Stefan




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

* Re: New global bindings
  2008-06-03 15:56 New global bindings Stefan Monnier
@ 2008-06-03 16:13 ` Miles Bader
  2008-06-03 18:44   ` joakim
  2008-06-03 16:39 ` M Jared Finder
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Miles Bader @ 2008-06-03 16:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> I have some problems with the new global bindings for C--, C-=, and C-+:
> 1- they're not mentioned in etc/NEWS (it seems none of the face-remap
>     feature is mentioned there).
> 2- (control -) was used for negative prefix arguments, so this is
>     a significant change for oldtimers.
> 3- these are very short key-bindings for a feature that does not seem to
>    require them: you're unlikely to want to do it that frequently.
>
> Point nb 1 is easy to fix, maybe I can live with nb 3, but nb 2 seems to
> be more problematic.  So I think we need to find some other key-bindings
> for that.  I think a prefix key followed by +, -, and = (repeatable like
> C-x e e e e e, maybe even allowing switching between + and -) is the
> best choice.

I used those particulars bindings are because lots of other popular apps
use them for this purpose (offhand, gnome apps and firefox, but
certainly more than that).

GIven that there about 47 different ways to enter a negative prefix
argument, and this one can't even be used on terminals -- so _real_ old
timers probably won't use it -- is point (2) really such a big deal?

-Miles

-- 
The key to happiness
 is having dreams.      [from a fortune cookie]




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

* Re: New global bindings
  2008-06-03 15:56 New global bindings Stefan Monnier
  2008-06-03 16:13 ` Miles Bader
@ 2008-06-03 16:39 ` M Jared Finder
  2008-06-03 17:13   ` Drew Adams
  2008-06-04  2:50   ` Miles Bader
  2008-06-03 16:55 ` Eric Hanchrow
  2008-06-03 17:35 ` Paul R
  3 siblings, 2 replies; 17+ messages in thread
From: M Jared Finder @ 2008-06-03 16:39 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier wrote:
> I have some problems with the new global bindings for C--, C-=, and C-+:
> 1- they're not mentioned in etc/NEWS (it seems none of the face-remap
>     feature is mentioned there).
> 2- (control -) was used for negative prefix arguments, so this is
>     a significant change for oldtimers.
> 3- these are very short key-bindings for a feature that does not seem to
>    require them: you're unlikely to want to do it that frequently.
> 
> Point nb 1 is easy to fix, maybe I can live with nb 3, but nb 2 seems to
> be more problematic.  So I think we need to find some other key-bindings
> for that.  I think a prefix key followed by +, -, and = (repeatable like
> C-x e e e e e, maybe even allowing switching between + and -) is the
> best choice.

As a user, I agree very much with this sentiment.  Very few editors even 
support C-+/C-- zooming; that's generally a viewer binding.  I would be 
happy with C-x C-+/C-x C-- bindings.

   -- MJF





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

* Re: New global bindings
  2008-06-03 15:56 New global bindings Stefan Monnier
  2008-06-03 16:13 ` Miles Bader
  2008-06-03 16:39 ` M Jared Finder
@ 2008-06-03 16:55 ` Eric Hanchrow
  2008-06-03 17:35 ` Paul R
  3 siblings, 0 replies; 17+ messages in thread
From: Eric Hanchrow @ 2008-06-03 16:55 UTC (permalink / raw)
  To: emacs-devel

I like the idea of C-- reducing the font, and C-+ enlarging it, thus
making Emacs more like other apps.
-- 
... a physicist of my acquaintance confiscated my copies of The
Tao of Physics and The Dancing Wu-li Masters and wouldn't let me have
them back even when I threatened to sue.
        -- Megan McArdle (writing as "Jane Galt")





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

* RE: New global bindings
  2008-06-03 16:39 ` M Jared Finder
@ 2008-06-03 17:13   ` Drew Adams
  2008-06-04  2:08     ` Miles Bader
  2008-06-04  2:50   ` Miles Bader
  1 sibling, 1 reply; 17+ messages in thread
From: Drew Adams @ 2008-06-03 17:13 UTC (permalink / raw)
  To: 'M Jared Finder', emacs-devel

> > I have some problems with the new global bindings for C--, 
> > C-=, and C-+: 1- they're not mentioned in etc/NEWS (it
> >     seems none of the face-remap feature is mentioned there).
> > 2- (control -) was used for negative prefix arguments, so this is
> >     a significant change for oldtimers.
> > 3- these are very short key-bindings for a feature that 
> >     does not seem to require them: you're unlikely to want to do
> >     it that frequently.
> > 
> > Point nb 1 is easy to fix, maybe I can live with nb 3, but 
> > nb 2 seems to be more problematic.  So I think we need to
> > find some other key-bindings for that.  I think a prefix key
> > followed by +, -, and = (repeatable like C-x e e e e e, maybe
> > even allowing switching between + and -) is the best choice.
> 
> As a user, I agree very much with this sentiment.  Very few 
> editors even support C-+/C-- zooming; that's generally a viewer
> binding. I would be happy with C-x C-+/C-x C-- bindings.

I agree, and I already said the same thing.

There is no need to co-opt such short keys, especially a key (`C--') that is
already bound and very useful. Please use a repeatable prefix key, as suggested,
if you make any key bindings at all for this.

Please do one of the following:

1. Don't bind any keys in this library. Include binding
   suggestions in the Commentary, if you like.
2. Bind keys only in a minor-mode map.







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

* Re: New global bindings
  2008-06-03 15:56 New global bindings Stefan Monnier
                   ` (2 preceding siblings ...)
  2008-06-03 16:55 ` Eric Hanchrow
@ 2008-06-03 17:35 ` Paul R
  3 siblings, 0 replies; 17+ messages in thread
From: Paul R @ 2008-06-03 17:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Miles Bader

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Point nb 1 is easy to fix, maybe I can live with nb 3, but nb 2 seems to
> be more problematic.  So I think we need to find some other key-bindings
> for that.  I think a prefix key followed by +, -, and = (repeatable like
> C-x e e e e e, maybe even allowing switching between + and -) is the
> best choice.

It is one more case where I think emacs should provide a binding of
the form C-x C-+ + + + + ...

'+' would mean "repeat last command" as long as no other key is hit.
Additionnaly, we could declare "-" as a valid candidate.
Why not :

(global-set-key-autorepeat '("\C-x\C-" . ("+" . zoom-in)
                                         ("-" . zoom-out)))

to allow auto-repeat on + and - after either C-x C-- or C-x C-+. 

I'd be happy if emacs could provide a primitive for this. It could
display a transient helper in the echo area to remind what keys are
temporary bound to special functions.

Currently, I use the following code :

;;;; Auto-repeat any command by pressing last shortcut key
(defun auto-repeat-command (command)
  (let ((repeat-repeat-char
         (when (eq last-command-char
                   last-command-event)
           last-command-char)))
    (call-interactively command)
    (while (eq (read-event) repeat-repeat-char)
      ;; Make each repetition undo separately.
      (auto-repeat-command command)
      (setq unread-command-events (list last-input-event)))))


then, for example :

(global-set-key "\C-xmn" (lambda () (interactive) (auto-repeat-command 'marker-visit-next)))

This is clearly not optimal, but it works and I have not looked for a
cleaner implementation, yet.

This type of binding is ideal for any command that :
 - is not very often called
 - when called, will probably be called several time in a row
They are a lot of places where such default behaviour would provide
intuitive and non-intrusive bindings.

What do you think ?

-- 
      Paul




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

* Re: New global bindings
  2008-06-03 16:13 ` Miles Bader
@ 2008-06-03 18:44   ` joakim
  2008-06-03 23:39     ` Miles Bader
  0 siblings, 1 reply; 17+ messages in thread
From: joakim @ 2008-06-03 18:44 UTC (permalink / raw)
  To: Miles Bader; +Cc: Stefan Monnier, emacs-devel

Miles Bader <miles@gnu.org> writes:


> I used those particulars bindings are because lots of other popular apps
> use them for this purpose (offhand, gnome apps and firefox, but
> certainly more than that).

I have really missed this feature, so thanks! Finally I can easily show
code to co-workers, and type messages to my son.

Some notes:

- A prefix, repeatable, keybinding like Stefan suggested would be quite
ok for usage. When you change font size, you want to conveniently find
the right one, but you dont want to do it all the time.

- try opening face-remap.el, and make the font really really small.
On line 180, as well as other places,  indentation becomes weird,
probably because tab-width is being computed wrongly or something.


-- 
Joakim Verona




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

* Re: New global bindings
  2008-06-03 18:44   ` joakim
@ 2008-06-03 23:39     ` Miles Bader
  0 siblings, 0 replies; 17+ messages in thread
From: Miles Bader @ 2008-06-03 23:39 UTC (permalink / raw)
  To: joakim; +Cc: Stefan Monnier, emacs-devel

joakim@verona.se writes:
> - try opening face-remap.el, and make the font really really small.
> On line 180, as well as other places,  indentation becomes weird,
> probably because tab-width is being computed wrongly or something.

If I recall correctly, there's currently a single tab "basis" (the
character width which buffer tab-widths are a multiple of) for the
entire frame.  This can also be noticed if you use tabs in text covered
by an explicit face property (and in the past, sometimes changing the
frame font didn't update it properly, leading to similarly weird
effects).

It should really be calculated dynamically.  I've been meaning to look
into fixing this.

-Miles

-- 
Genealogy, n. An account of one's descent from an ancestor who did not
particularly care to trace his own.




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

* Re: New global bindings
  2008-06-03 17:13   ` Drew Adams
@ 2008-06-04  2:08     ` Miles Bader
  0 siblings, 0 replies; 17+ messages in thread
From: Miles Bader @ 2008-06-04  2:08 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'M Jared Finder', emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
> 1. Don't bind any keys in this library. Include binding
>    suggestions in the Commentary, if you like.

That is clearly unacceptable.

-Miles

-- 
Dictionary, n.  A malevolent literary device for cramping the growth of
a language and making it hard and inelastic. This dictionary, however,
is a most useful work.




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

* Re: New global bindings
  2008-06-03 16:39 ` M Jared Finder
  2008-06-03 17:13   ` Drew Adams
@ 2008-06-04  2:50   ` Miles Bader
  2008-06-04  3:46     ` Stefan Monnier
  2008-06-04 10:43     ` joakim
  1 sibling, 2 replies; 17+ messages in thread
From: Miles Bader @ 2008-06-04  2:50 UTC (permalink / raw)
  To: M Jared Finder; +Cc: Stefan Monnier, emacs-devel

M Jared Finder <jared@hpalace.com> writes:
> I would be happy with C-x C-+/C-x C-- bindings.

Please try the following:

(define-key ctl-x-map [(control ?+)] 'incdec-buffer-face-height)
(define-key ctl-x-map [(control ?-)] 'incdec-buffer-face-height)
(define-key ctl-x-map [(control ?=)] 'incdec-buffer-face-height)
(define-key ctl-x-map [(control ?0)] 'incdec-buffer-face-height)

(defun incdec-buffer-face-height (&optional inc)
  "Increase or decrease the height of the default face in the current buffer.

Then, continue to read input events and increase/decrease the
face height as long as the input events with all modifiers
removed are one of the following:

   +, =   Increase the default face height by one step
   -      Decrease the default face height by one step
   0      Reset the default face height to the global default

Each step scales the height of the default face by the variable
`text-scale-mode-step' (a negative number of steps decreases the
height by the same amount).  As a special case, an argument of 0
will remove any scaling currently active.

This command is a special-purpose wrapper around the
`increase-buffer-face-height' command which makes repetition
convenient even when it is bound in a non-top-level keymap.  For
binding in a top-level keymap, `increase-buffer-face-height' or
`decrease-default-face-height' may be more appropriate."
  (interactive "p")
  (let ((first t) 
	(step t)
	(ev last-command-event))
    (while step
      (let ((base (event-basic-type ev)))
	(cond ((or (eq base ?+) (eq base ?=))
	       (setq step inc))
	      ((eq base ?-)
	       (setq step (- inc)))
	      ((eq base ?0)
	       (setq step 0))
	      (first 
	       (setq step inc))
	      (t
	       (setq step nil))))
      (when step
	(increase-buffer-face-height step)
	(setq inc 1 first nil)
	(setq ev (read-event))))
    (push ev unread-command-events)))


Thanks,

-Miles

-- 
Education, n. That which discloses to the wise and disguises from the foolish
their lack of understanding.




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

* Re: New global bindings
  2008-06-04  2:50   ` Miles Bader
@ 2008-06-04  3:46     ` Stefan Monnier
  2008-06-04  3:53       ` Miles Bader
  2008-06-04 10:43     ` joakim
  1 sibling, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2008-06-04  3:46 UTC (permalink / raw)
  To: Miles Bader; +Cc: M Jared Finder, emacs-devel

>> I would be happy with C-x C-+/C-x C-- bindings.
> Please try the following:

Looks good.  Could you be careful with the namespaces, tho?
E.g. use a "face-remap-" prefix for things in face-remap.el or something
like that?


        Stefan




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

* Re: New global bindings
  2008-06-04  3:46     ` Stefan Monnier
@ 2008-06-04  3:53       ` Miles Bader
  2008-06-04  5:11         ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Miles Bader @ 2008-06-04  3:53 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: M Jared Finder, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Looks good.  Could you be careful with the namespaces, tho?
> E.g. use a "face-remap-" prefix for things in face-remap.el or something
> like that?

I prefer to use traditional elisp/lisp naming conventions.

-Miles

-- 
"Whatever you do will be insignificant, but it is very important that
 you do it."  Mahatma Gandhi




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

* Re: New global bindings
  2008-06-04  3:53       ` Miles Bader
@ 2008-06-04  5:11         ` Stefan Monnier
  0 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2008-06-04  5:11 UTC (permalink / raw)
  To: Miles Bader; +Cc: M Jared Finder, emacs-devel

>> Looks good.  Could you be careful with the namespaces, tho?
>> E.g. use a "face-remap-" prefix for things in face-remap.el or something
>> like that?

> I prefer to use traditional elisp/lisp naming conventions.

That's a good convention for core functionality, but it the lack of
namespace support in Elisp makes it desirable to carefully use prefixes
for everything else.

Of course, you may call your rescaler "core-functionality", but I'd tend
to only include in "core functionality" things that are closer to
"libraries" than to "user commands".


        Stefan




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

* Re: New global bindings
  2008-06-04  2:50   ` Miles Bader
  2008-06-04  3:46     ` Stefan Monnier
@ 2008-06-04 10:43     ` joakim
  2008-06-04 13:30       ` Miles Bader
  1 sibling, 1 reply; 17+ messages in thread
From: joakim @ 2008-06-04 10:43 UTC (permalink / raw)
  To: Miles Bader; +Cc: M Jared Finder, Stefan Monnier, emacs-devel

Seems to work nicely, thanks!

Caveats:

- Why is "=" bound to the same as "+"?
Is it because of the kbd layout you use?

- Could there be menu entries to help find this feature?

- "c-x c-+ +" also increases height. Is that desired?

- should c-g exit and restore default size?

- "c-x c-+ p" exits size change as expected, but leaves
a confusing "c-x c-+ p" message in the minibuffer.

- a message similar to "c-x e" "type 'e' to repeat macro" would be nice

Thanks again for this useful feature!


Miles Bader <miles.bader@necel.com> writes:

> M Jared Finder <jared@hpalace.com> writes:
>> I would be happy with C-x C-+/C-x C-- bindings.
>
> Please try the following:
>
> (define-key ctl-x-map [(control ?+)] 'incdec-buffer-face-height)
> (define-key ctl-x-map [(control ?-)] 'incdec-buffer-face-height)
> (define-key ctl-x-map [(control ?=)] 'incdec-buffer-face-height)
> (define-key ctl-x-map [(control ?0)] 'incdec-buffer-face-height)
>
...

>
> Thanks,
>
> -Miles
-- 
Joakim Verona




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

* Re: New global bindings
  2008-06-04 10:43     ` joakim
@ 2008-06-04 13:30       ` Miles Bader
  2008-06-04 14:35         ` Juanma Barranquero
  0 siblings, 1 reply; 17+ messages in thread
From: Miles Bader @ 2008-06-04 13:30 UTC (permalink / raw)
  To: joakim; +Cc: M Jared Finder, Stefan Monnier, emacs-devel

joakim@verona.se writes:
> - Why is "=" bound to the same as "+"?
> Is it because of the kbd layout you use?

Because that's a fairly common binding (e.g., firefox) -- "+" is a
shifted key on U.S. keyboard layouts, but "=" is the same key unshifted,
and is next to the "-" key.  So for convenient use, "-" and "=" actually
make a good pair.

> - Could there be menu entries to help find this feature?

Dunno

> - "c-x c-+ +" also increases height. Is that desired?

Seems ok to me.

> - should c-g exit and restore default size?

I don't really know, but offhand I don't think so -- it's not really
supposed to seem like you're in some little "mode", but rather give the
impression that you're repeating the command without needing to type
C-x.

> - "c-x c-+ p" exits size change as expected, but leaves
> a confusing "c-x c-+ p" message in the minibuffer.

I don' t know how to control the funny echo-area messages for prefix keys.

-miles

-- 
Yo mama's so fat when she gets on an elevator it HAS to go down.




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

* Re: New global bindings
  2008-06-04 13:30       ` Miles Bader
@ 2008-06-04 14:35         ` Juanma Barranquero
  2008-06-04 18:38           ` Stephen Berman
  0 siblings, 1 reply; 17+ messages in thread
From: Juanma Barranquero @ 2008-06-04 14:35 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

Testing face-remap with linum-mode, a small limitation does show up:
margin width is computed in character cells (according to the docs of
`set-window-margins'), but obviously it does not take
`face-remapping-alist' into account.

 Juanma




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

* Re: New global bindings
  2008-06-04 14:35         ` Juanma Barranquero
@ 2008-06-04 18:38           ` Stephen Berman
  0 siblings, 0 replies; 17+ messages in thread
From: Stephen Berman @ 2008-06-04 18:38 UTC (permalink / raw)
  To: emacs-devel

On Wed, 4 Jun 2008 16:35:41 +0200 "Juanma Barranquero" <lekktu@gmail.com> wrote:

> Testing face-remap with linum-mode, a small limitation does show up:
> margin width is computed in character cells (according to the docs of
> `set-window-margins'), but obviously it does not take
> `face-remapping-alist' into account.

This also reveals a linum bug: linum-mode fails to update the display
when the font size changes.  E.g., with linum-mode enabled type C-x C--
and then there is text at the bottom of the the window with no line
numbering in the margin (if the text in the buffer is long enough).

Steve Berman





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

end of thread, other threads:[~2008-06-04 18:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-03 15:56 New global bindings Stefan Monnier
2008-06-03 16:13 ` Miles Bader
2008-06-03 18:44   ` joakim
2008-06-03 23:39     ` Miles Bader
2008-06-03 16:39 ` M Jared Finder
2008-06-03 17:13   ` Drew Adams
2008-06-04  2:08     ` Miles Bader
2008-06-04  2:50   ` Miles Bader
2008-06-04  3:46     ` Stefan Monnier
2008-06-04  3:53       ` Miles Bader
2008-06-04  5:11         ` Stefan Monnier
2008-06-04 10:43     ` joakim
2008-06-04 13:30       ` Miles Bader
2008-06-04 14:35         ` Juanma Barranquero
2008-06-04 18:38           ` Stephen Berman
2008-06-03 16:55 ` Eric Hanchrow
2008-06-03 17:35 ` Paul R

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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