unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Changing the factor used in universal arugment
@ 2017-06-24 15:06 Narendra Joshi
  2017-06-24 16:22 ` John Ankarström
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Narendra Joshi @ 2017-06-24 15:06 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

How can I change the factor by which universal argument changes on
repetition from 4 to say 2? For say having more granularity there.

Best, 
-- 
Narendra Joshi



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

* Re: Changing the factor used in universal arugment
  2017-06-24 15:06 Changing the factor used in universal arugment Narendra Joshi
@ 2017-06-24 16:22 ` John Ankarström
  2017-06-24 18:39   ` Emanuel Berg
  2017-06-24 16:26 ` Kaushal Modi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: John Ankarström @ 2017-06-24 16:22 UTC (permalink / raw)
  To: help-gnu-emacs

Hi!

narendra joshi <narendraj9@gmail.com> writes:

> how can i change the factor by which universal argument changes on
> repetition from 4 to say 2? for say having more granularity there.

Whether or not it's possible, that probably isn't a very good
idea, as many functions depend on the assumption that a single
C-u sends an argument of 4 or '(4), and that C-u C-u means 16,
and so forth.

In retrospect, it might have been better if C-u was internally
represented in some other way, but that's the way it is and it's
too late to change it ... :-)

- John



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

* Re: Changing the factor used in universal arugment
  2017-06-24 15:06 Changing the factor used in universal arugment Narendra Joshi
  2017-06-24 16:22 ` John Ankarström
@ 2017-06-24 16:26 ` Kaushal Modi
  2017-06-24 18:47   ` Emanuel Berg
  2017-06-24 17:42 ` Udyant Wig
  2017-06-24 17:49 ` Emanuel Berg
  3 siblings, 1 reply; 14+ messages in thread
From: Kaushal Modi @ 2017-06-24 16:26 UTC (permalink / raw)
  To: Narendra Joshi, help-gnu-emacs

On Sat, Jun 24, 2017 at 11:06 AM Narendra Joshi <narendraj9@gmail.com>
wrote:

> For say having more granularity there.
>

It will be useful to understand your use case here.

If you mean granularity in movement functions for example, then you can
have a wrapper function that interprets C-u, C-u C-u, .. differently, and
then use the same wrapper fn to advice multiple fns in a loop.
-- 

Kaushal Modi


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

* Re: Changing the factor used in universal arugment
  2017-06-24 15:06 Changing the factor used in universal arugment Narendra Joshi
  2017-06-24 16:22 ` John Ankarström
  2017-06-24 16:26 ` Kaushal Modi
@ 2017-06-24 17:42 ` Udyant Wig
  2017-06-24 23:56   ` John Ankarström
  2017-06-25  5:28   ` Narendra Joshi
  2017-06-24 17:49 ` Emanuel Berg
  3 siblings, 2 replies; 14+ messages in thread
From: Udyant Wig @ 2017-06-24 17:42 UTC (permalink / raw)
  To: help-gnu-emacs

On 06/24/2017 08:36 PM, Narendra Joshi wrote:
> Hi,
> 
> How can I change the factor by which universal argument changes on
> repetition from 4 to say 2? For say having more granularity there.
> 
> Best, 

What precisely do you have in mind?  What do you want to achieve?  If
the default value of C-u, which is 4, is too blunt an instrument for
your purpose, have you tried the arbitrary numeric prefixes, say, C-3 or
M-5, just to specify two?

-- 
... while the ways of art are hard at the best, they will break you if
you go unsustained by belief in what you are trying to do.
                                -- Arthur Quiller-Couch




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

* Re: Changing the factor used in universal arugment
  2017-06-24 15:06 Changing the factor used in universal arugment Narendra Joshi
                   ` (2 preceding siblings ...)
  2017-06-24 17:42 ` Udyant Wig
@ 2017-06-24 17:49 ` Emanuel Berg
  3 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2017-06-24 17:49 UTC (permalink / raw)
  To: help-gnu-emacs

Narendra Joshi wrote:

> How can I change the factor by which
> universal argument changes on repetition from
> 4 to say 2? For say having more
> granularity there.

1. Use the source, Luke! First do `C-h k C-u'
   to find out what function is bound to the
   key and where it is defined.

2. Open the file:

       /usr/share/emacs/24.4/lisp/simple.el.gz

3. Copy these functions to some other file:

       universal-argument
       universal-argument-more

4. Change the 4s into 2s. [1]

5. Evaluate the functions (or entire new file)
   to have them overload the
   previous definitions.

6. Don't do it, Jeff!



[1] Hey, same data hard-coded twice - not good!

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: Changing the factor used in universal arugment
  2017-06-24 16:22 ` John Ankarström
@ 2017-06-24 18:39   ` Emanuel Berg
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2017-06-24 18:39 UTC (permalink / raw)
  To: help-gnu-emacs

john@ankarstrom.se (John Ankarström) writes:

> In retrospect, it might have been better if C-u was
> internally represented in some other way, but that's
> the way it is and it's too late to change it ... :-)

What's wrong with 4? You typically want to do it
*once* and then you want it to have an impact. 2 is
too small to have an impact and 3 you can tap
ba-ba-bam on the key fast enough.

But I do agree it shouldn't be changed :)

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: Changing the factor used in universal arugment
  2017-06-24 16:26 ` Kaushal Modi
@ 2017-06-24 18:47   ` Emanuel Berg
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2017-06-24 18:47 UTC (permalink / raw)
  To: help-gnu-emacs

Kaushal Modi <kaushal.modi@gmail.com> writes:

> If you mean granularity in movement functions for
> example, then you can have a wrapper function that
> interprets C-u, C-u C-u, .. differently, and then
> use the same wrapper fn to advice multiple fns in
> a loop.

Good idea ... but is this easy or difficult to do?

For a single function, is it enough to divide by 4 and
then multiply by the new value?

An advice could be used for a new function but then it
might as well do it itself. Unless there are several
new functions who all need this!

For an old function a user-defined advice may be
risky: is the user aware of all entry points? also, it
might screw up interactiveness - here I might be wrong
tho because I never liked advices to begin with so
I have close to zero experience - just a hunch...

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: Changing the factor used in universal arugment
  2017-06-24 17:42 ` Udyant Wig
@ 2017-06-24 23:56   ` John Ankarström
  2017-06-25 14:37     ` Emanuel Berg
  2017-06-25  5:28   ` Narendra Joshi
  1 sibling, 1 reply; 14+ messages in thread
From: John Ankarström @ 2017-06-24 23:56 UTC (permalink / raw)
  To: help-gnu-emacs

Udyant Wig <udyant.wig@gmail.com> writes:

> What precisely do you have in mind?  What do you want to achieve?  If
> the default value of C-u, which is 4, is too blunt an instrument for
> your purpose, have you tried the arbitrary numeric prefixes, say, C-3 or
> M-5, just to specify two?

This! C-2 is just as simple as C-u. The only difference is you
can't multiply it, like C-u C-u C-u.

- John



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

* Re: Changing the factor used in universal arugment
  2017-06-24 17:42 ` Udyant Wig
  2017-06-24 23:56   ` John Ankarström
@ 2017-06-25  5:28   ` Narendra Joshi
  1 sibling, 0 replies; 14+ messages in thread
From: Narendra Joshi @ 2017-06-25  5:28 UTC (permalink / raw)
  To: Udyant Wig; +Cc: help-gnu-emacs

Udyant Wig <udyant.wig@gmail.com> writes:

> On 06/24/2017 08:36 PM, Narendra Joshi wrote:
>> Hi,
>> 
>> How can I change the factor by which universal argument changes on
>> repetition from 4 to say 2? For say having more granularity there.
>> 
>> Best, 
>
> What precisely do you have in mind?  What do you want to achieve?  If
> the default value of C-u, which is 4, is too blunt an instrument for
> your purpose, have you tried the arbitrary numeric prefixes, say, C-3 or
> M-5, just to specify two?
I was trying to achieve the following:

I changed `prefix-command-preserve-state-hook' to momentarily enable
`linum-relative-mode` on C-u, this would help me guess how many times I
need to repeatedly press C-u get to a specific line. With a
multiplicative factor of 4, I found it hard to get to every line
easily.

I think I should just use something else for my use case. Maybe
`avy-goto-line`. 

Best,
-- 
Narendra Joshi



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

* Re: Changing the factor used in universal arugment
  2017-06-24 23:56   ` John Ankarström
@ 2017-06-25 14:37     ` Emanuel Berg
  2017-06-25 17:41       ` John Ankarström
  0 siblings, 1 reply; 14+ messages in thread
From: Emanuel Berg @ 2017-06-25 14:37 UTC (permalink / raw)
  To: help-gnu-emacs

john@ankarstrom.se (John Ankarström) writes:

>> What precisely do you have in mind? What do you
>> want to achieve? If the default value of C-u, which
>> is 4, is too blunt an instrument for your purpose,
>> have you tried the arbitrary numeric prefixes, say,
>> C-3 or M-5, just to specify two?
>
> This! C-2 is just as simple as C-u. The only
> difference is you can't multiply it, like C-u C-u
> C-u.

`C-u 2' (or C-u whatever) is even more simple and it
doesn't get more arbitrary than that. Well, possibly
papal rule in the Vatican was even more arbitrary...

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: Changing the factor used in universal arugment
  2017-06-25 14:37     ` Emanuel Berg
@ 2017-06-25 17:41       ` John Ankarström
  2017-06-25 18:01         ` Emanuel Berg
  0 siblings, 1 reply; 14+ messages in thread
From: John Ankarström @ 2017-06-25 17:41 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <moasen@zoho.com> writes:

> john@ankarstrom.se (John Ankarström) writes:
>
>> This! C-2 is just as simple as C-u. The only
>> difference is you can't multiply it, like C-u C-u
>> C-u.
>
> `C-u 2' (or C-u whatever) is even more simple and it
> doesn't get more arbitrary than that. Well, possibly
> papal rule in the Vatican was even more arbitrary...

C-2 is arguably simpler than C-u 2, as the latter requires more
keypresses, but in the end, who cares? :-)

- John



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

* Re: Changing the factor used in universal arugment
  2017-06-25 17:41       ` John Ankarström
@ 2017-06-25 18:01         ` Emanuel Berg
  2017-06-25 20:08           ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Emanuel Berg @ 2017-06-25 18:01 UTC (permalink / raw)
  To: help-gnu-emacs

john@ankarstrom.se (John Ankarström) writes:

> C-2 is arguably simpler than C-u 2, as the latter
> requires more keypresses

C-u is more general because after that whatever digit
can follow. It is much more useful to get used to and
get into the muscle memory.

C-2 is unergonomic, at least on my keyboard.

The C-2s and M-2s, etc., doesn't work in a console or
-nw Emacs instance without the workaround. And if you
do it, probably you want to use it for something
better than replicate the C-u functionality which is
readily available.

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: Changing the factor used in universal arugment
  2017-06-25 18:01         ` Emanuel Berg
@ 2017-06-25 20:08           ` Stefan Monnier
  2017-06-25 20:29             ` Emanuel Berg
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2017-06-25 20:08 UTC (permalink / raw)
  To: help-gnu-emacs

> The C-2s and M-2s, etc., doesn't work in a console or

While C-2 is indeed problematic in ttys, M-2 should work fine (and if
not it should be easy to make it work, since you should easily be able
to configure your terminal emulator or console to map the M- modifier to
an ESC prefix byte).


        Stefan




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

* Re: Changing the factor used in universal arugment
  2017-06-25 20:08           ` Stefan Monnier
@ 2017-06-25 20:29             ` Emanuel Berg
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2017-06-25 20:29 UTC (permalink / raw)
  To: help-gnu-emacs

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

> While C-2 is indeed problematic in ttys, M-2 should
> work fine

You are right, they do!

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

end of thread, other threads:[~2017-06-25 20:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-24 15:06 Changing the factor used in universal arugment Narendra Joshi
2017-06-24 16:22 ` John Ankarström
2017-06-24 18:39   ` Emanuel Berg
2017-06-24 16:26 ` Kaushal Modi
2017-06-24 18:47   ` Emanuel Berg
2017-06-24 17:42 ` Udyant Wig
2017-06-24 23:56   ` John Ankarström
2017-06-25 14:37     ` Emanuel Berg
2017-06-25 17:41       ` John Ankarström
2017-06-25 18:01         ` Emanuel Berg
2017-06-25 20:08           ` Stefan Monnier
2017-06-25 20:29             ` Emanuel Berg
2017-06-25  5:28   ` Narendra Joshi
2017-06-24 17:49 ` Emanuel Berg

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