unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Simple keybinding request
@ 2017-04-09 10:05 Sharon Kimble
  2017-04-09 10:22 ` Danny YUE
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sharon Kimble @ 2017-04-09 10:05 UTC (permalink / raw)
  To: help-emacs

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]


How can I bind '<ref name="%"/>' to some keys to make it easier to enter
please? I've got it as a yasnippet but its using 5 keys to enter it, and
if I can just use say 3 keys it will speed things up. What it actually
does is to enter a citation-repeat in mediawiki-mode.

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 8.6, fluxbox 1.3.5-2, emacs 25.1.1.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* Re: Simple keybinding request
  2017-04-09 10:05 Simple keybinding request Sharon Kimble
@ 2017-04-09 10:22 ` Danny YUE
  2017-04-09 13:03   ` Sharon Kimble
  2017-04-09 11:46 ` Yuri Khan
  2017-04-22  0:59 ` Emanuel Berg
  2 siblings, 1 reply; 7+ messages in thread
From: Danny YUE @ 2017-04-09 10:22 UTC (permalink / raw)
  To: Sharon Kimble; +Cc: help-emacs


On 2017-04-09 10:05, Sharon Kimble <boudiccas@skimble.plus.com> wrote:
> How can I bind '<ref name="%"/>' to some keys to make it easier to enter
> please? I've got it as a yasnippet but its using 5 keys to enter it, and
> if I can just use say 3 keys it will speed things up. What it actually
> does is to enter a citation-repeat in mediawiki-mode.
>
> Thanks
> Sharon.

Try below whiling editing your new yasnippet item:

# -*- mode: snippet -*-
# name: ref
# key: ref
# --
<ref name="$0"/>

The snippet above binds the snippet to "ref" key.
'$0' makes the cursor move there after expansion completed.

Good luck.

Danny



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

* Re: Simple keybinding request
  2017-04-09 10:05 Simple keybinding request Sharon Kimble
  2017-04-09 10:22 ` Danny YUE
@ 2017-04-09 11:46 ` Yuri Khan
  2017-04-09 12:49   ` Sharon Kimble
  2017-04-22  0:59 ` Emanuel Berg
  2 siblings, 1 reply; 7+ messages in thread
From: Yuri Khan @ 2017-04-09 11:46 UTC (permalink / raw)
  To: Sharon Kimble; +Cc: help-emacs

On Sun, Apr 9, 2017 at 5:05 PM, Sharon Kimble
<boudiccas@skimble.plus.com> wrote:

> How can I bind '<ref name="%"/>' to some keys to make it easier to enter
> please? I've got it as a yasnippet but its using 5 keys to enter it, and
> if I can just use say 3 keys it will speed things up. What it actually
> does is to enter a citation-repeat in mediawiki-mode.

I was going to suggest yasnippet but I see you’re already using that :)

I assume the 5 keys you have now are `< r e f TAB`. If not, please elaborate.

You can shorten that to `< r TAB` by editing the snippet (M-x
yas-visit-snippet-file), changing the `# key: <ref` line to `# key:
<r` and installing the changed snippet with `C-c C-c`.

You could do away with the initial `<` if you didn’t ever need to use
the snippet immediately after a word, like `foo<ref…`. However, with
footnotes and references, you often do, so you need a non-letter at
the start of the key.

Alternatively, you could bind the snippet directly to a key by
specifying a `# binding:` directive in the snippet file. For example,
`# binding: M-r` or `# binding: C-c w r`.



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

* Re: Simple keybinding request
  2017-04-09 11:46 ` Yuri Khan
@ 2017-04-09 12:49   ` Sharon Kimble
  0 siblings, 0 replies; 7+ messages in thread
From: Sharon Kimble @ 2017-04-09 12:49 UTC (permalink / raw)
  To: Yuri Khan; +Cc: help-emacs

[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Sun, Apr 9, 2017 at 5:05 PM, Sharon Kimble
> <boudiccas@skimble.plus.com> wrote:
>
>> How can I bind '<ref name="%"/>' to some keys to make it easier to enter
>> please? I've got it as a yasnippet but its using 5 keys to enter it, and
>> if I can just use say 3 keys it will speed things up. What it actually
>> does is to enter a citation-repeat in mediawiki-mode.
>
> I was going to suggest yasnippet but I see you’re already using that :)
>
> I assume the 5 keys you have now are `< r e f TAB`. If not, please
> elaborate.

Thanks for replying Yuri.

Its actually bound to 'crep' (meaning citation-repeat).

>
> You can shorten that to `< r TAB` by editing the snippet (M-x
> yas-visit-snippet-file), changing the `# key: <ref` line to `# key:
> <r` and installing the changed snippet with `C-c C-c`.
>
> You could do away with the initial `<` if you didn’t ever need to use
> the snippet immediately after a word, like `foo<ref…`. However, with
> footnotes and references, you often do, so you need a non-letter at
> the start of the key.
>
> Alternatively, you could bind the snippet directly to a key by
> specifying a `# binding:` directive in the snippet file. For example,
> `# binding: M-r` or `# binding: C-c w r`.

Thanks for this, its now bound to 'M-s-SPC' which makes it all a lot
easier to use.

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 8.6, fluxbox 1.3.5-2, emacs 25.1.1.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* Re: Simple keybinding request
  2017-04-09 10:22 ` Danny YUE
@ 2017-04-09 13:03   ` Sharon Kimble
  2017-04-09 16:12     ` Danny YUE
  0 siblings, 1 reply; 7+ messages in thread
From: Sharon Kimble @ 2017-04-09 13:03 UTC (permalink / raw)
  To: Danny YUE; +Cc: help-emacs

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

Danny YUE <sheepduke@gmail.com> writes:

> On 2017-04-09 10:05, Sharon Kimble <boudiccas@skimble.plus.com> wrote:
>> How can I bind '<ref name="%"/>' to some keys to make it easier to enter
>> please? I've got it as a yasnippet but its using 5 keys to enter it, and
>> if I can just use say 3 keys it will speed things up. What it actually
>> does is to enter a citation-repeat in mediawiki-mode.
>>
>> Thanks
>> Sharon.
>
> Try below whiling editing your new yasnippet item:
>

Thanks for replying Danny.

> # -*- mode: snippet -*-
> # name: ref
> # key: ref
> # --
> <ref name="$0"/>
>
> The snippet above binds the snippet to "ref" key.
> '$0' makes the cursor move there after expansion completed.

I didn't know about '$0' so thanks for that, its working very nicely.

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 8.6, fluxbox 1.3.5-2, emacs 25.1.1.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* Re: Simple keybinding request
  2017-04-09 13:03   ` Sharon Kimble
@ 2017-04-09 16:12     ` Danny YUE
  0 siblings, 0 replies; 7+ messages in thread
From: Danny YUE @ 2017-04-09 16:12 UTC (permalink / raw)
  To: Sharon Kimble; +Cc: help-emacs, Danny YUE


On 2017-04-09 13:03, Sharon Kimble <boudiccas@skimble.plus.com> wrote:
> Danny YUE <sheepduke@gmail.com> writes:
>
>> On 2017-04-09 10:05, Sharon Kimble <boudiccas@skimble.plus.com> wrote:
>>> How can I bind '<ref name="%"/>' to some keys to make it easier to enter
>>> please? I've got it as a yasnippet but its using 5 keys to enter it, and
>>> if I can just use say 3 keys it will speed things up. What it actually
>>> does is to enter a citation-repeat in mediawiki-mode.
>>>
>>> Thanks
>>> Sharon.
>>
>> Try below whiling editing your new yasnippet item:
>>
>
> Thanks for replying Danny.
>
>> # -*- mode: snippet -*-
>> # name: ref
>> # key: ref
>> # --
>> <ref name="$0"/>
>>
>> The snippet above binds the snippet to "ref" key.
>> '$0' makes the cursor move there after expansion completed.
>
> I didn't know about '$0' so thanks for that, its working very nicely.
>
> Thanks
> Sharon.

Just FYI:
Maybe you already guessed it, you can use '$1', '$2' etc to specify
manual completion positions and cycle them using key <TAB>.
If you specify multiple '$1', they will be updated simultaneously when
you edit one of them.
e.g. <input type="$1" id="$2" name=$2" />$0

Danny



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

* Re: Simple keybinding request
  2017-04-09 10:05 Simple keybinding request Sharon Kimble
  2017-04-09 10:22 ` Danny YUE
  2017-04-09 11:46 ` Yuri Khan
@ 2017-04-22  0:59 ` Emanuel Berg
  2 siblings, 0 replies; 7+ messages in thread
From: Emanuel Berg @ 2017-04-22  0:59 UTC (permalink / raw)
  To: help-gnu-emacs

Sharon Kimble wrote:

> How can I bind '<ref name="%"/>' to some keys
> to make it easier to enter please?

You can use a simpler method than the snippet
expansion stuff in the Emacs abbrevs.
You probably know how to do that but if not,
ask. For example, you could set it up to
"refn".

Or, you can do it manually, like this:

    (defun insert-ref-name ()
      (interactive)
      (insert "<ref name=\"%\"/>") )
    (global-set-key "\C-\M-]" #'insert-ref-name)

> I've got it as a yasnippet but its using 5
> keys to enter it, and if I can just use say 3
> keys it will speed things up.

Well, counting keys don't tell the whole story.
If you want to minimize the keydowns, a command
is the best.

Also, as always, it is not the number of
keydowns as much as where those keys are on
the keyboard. Typing "asd" is faster that
hitting F9, and not only "isolated" but also in
terms of flow because F9 requires resetting the
hands to "asd" and "jkl" positions!

The abbrev solution is probably the best in
terms of all of it, super-easy to setup, quick
to execute and non-disruptive as the typing
goes on and on...

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




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

end of thread, other threads:[~2017-04-22  0:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-09 10:05 Simple keybinding request Sharon Kimble
2017-04-09 10:22 ` Danny YUE
2017-04-09 13:03   ` Sharon Kimble
2017-04-09 16:12     ` Danny YUE
2017-04-09 11:46 ` Yuri Khan
2017-04-09 12:49   ` Sharon Kimble
2017-04-22  0:59 ` 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).