RE: How to search in digraphs?

40 views
Skip to first unread message

Christian Brabandt

unread,
Apr 12, 2012, 3:53:49 AM4/12/12
to vim...@googlegroups.com, vim...@googlegroups.com
On Thu, April 12, 2012 09:37, John Beckett wrote:
[forwarding to vim-dev]
> I needed to look at ':help digraph-table' and noticed
> something strange. There are 22 lines that have <space><grave>
> at the end, for example:
>
> - -N 2013 8211 EN DASH `
>
> However, the grave is hidden in the help.
>
> Is there a reason for the grave, or is it a documentation glitch?

That is probably a documentation glitch. I bet, the space grave
should be there at every entry, since this is used for syntax highlighting
help files (helpGraphics I think).

Additionally helpGraphic should also link to something so it
is highlighted in the help file, maybe Macro?

regards,
Christian

Christian Brabandt

unread,
Apr 12, 2012, 5:03:52 PM4/12/12
to vim...@googlegroups.com, vim-dev Mailingliste
Bram,

On Mi, 11 Apr 2012, Chris Jones wrote:

> Is there a format of the ‘:digraphs’ command that lets you list only
> custom user-defined digraphs - i.e. those that are different from the
> defaults..?
>
> Couldn't find such a thing in Vim 7.2..
>
> If there isn't, something like ‘:dig!’ would be nice..

Here is a patch, that makes :dig! display only user-defined digraphs and
:dig! xy remove the digraph, that is defined by the chars xy

This sounds like a useful addition.

regards,
Christian

digraphs.diff

Chris Jones

unread,
Apr 12, 2012, 11:03:32 PM4/12/12
to vim...@googlegroups.com, vim-dev Mailingliste

Not sure if/when I'll be able to test it since I'm on debian and I don't
have a vim source environment set up.

Shouldn't there be a patch against the digraph.txt help file as well..
or does that work differently..?

CJ

--
SOMEBODY SET UP US THE BOMB

Bram Moolenaar

unread,
Apr 13, 2012, 5:38:19 AM4/13/12
to Christian Brabandt, vim...@googlegroups.com, vim-dev Mailingliste

Christian Brabandt wrote:

If ":dig! xy" deletes a digraph I would expect ":dig!" to delete all
user-defined digraphs. Thus have "!" mean delete.

Can we use another command to list user-defined digraphs? Perhaps
":dig ?"?

This patch would also need documentation. And a test would be good too.

--
`When any government, or any church for that matter, undertakes to say to
its subjects, "This you may not read, this you must not see, this you are
forbidden to know," the end result is tyranny and oppression no matter how
holy the motives' -- Robert A Heinlein, "If this goes on --"

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Marvin Renich

unread,
Apr 13, 2012, 7:37:59 AM4/13/12
to vim-dev Mailinglist
* Bram Moolenaar <Br...@Moolenaar.net> [120413 05:42]:

> Christian Brabandt wrote:
> > Here is a patch, that makes :dig! display only user-defined digraphs and
> > :dig! xy remove the digraph, that is defined by the chars xy
> >
> > This sounds like a useful addition.
>
> If ":dig! xy" deletes a digraph I would expect ":dig!" to delete all
> user-defined digraphs. Thus have "!" mean delete.
>
> Can we use another command to list user-defined digraphs? Perhaps
> ":dig ?"?
>
> This patch would also need documentation. And a test would be good too.

Using :dig! to display and :dig! xy to delete is terribly inconsistent.
To remove a highlight, vim uses :hi clear, to remove a map, :unmap. I
would suggest :undig {char}{char} or :undig {number} to remove a
digraph.

:dig! {char}{char} or :dig! {number} could be used to list digraphs
matching certain criteria. I would even go so far as to allow :dig!
{char} to find all digraphs with the specified char in either position.
If char is ambiguous (i.e. a single digit or two digits) treat is as
both {char} or {char}{char} and {number} (list all matches).

While :dig! without arguments would list user-defined digraphs, :dig!
with an argument would list all matching digraphs, both pre-defined and
user-defined.

...Marvin

Benjamin R. Haskell

unread,
Apr 13, 2012, 5:09:37 PM4/13/12
to vim...@googlegroups.com
On Fri, 13 Apr 2012, Marvin Renich wrote:

> * Bram Moolenaar <Br...@Moolenaar.net> [120413 05:42]:
>> Christian Brabandt wrote:
>>> Here is a patch, that makes :dig! display only user-defined digraphs
>>> and :dig! xy remove the digraph, that is defined by the chars xy
>>>
>>> This sounds like a useful addition.
>>
>> If ":dig! xy" deletes a digraph I would expect ":dig!" to delete all
>> user-defined digraphs. Thus have "!" mean delete.
>>
>> Can we use another command to list user-defined digraphs? Perhaps
>> ":dig ?"?
>>
>> This patch would also need documentation. And a test would be good too.
>
> Using :dig! to display and :dig! xy to delete is terribly
> inconsistent. To remove a highlight, vim uses :hi clear, to remove a
> map, :unmap. I would suggest :undig {char}{char} or :undig {number}
> to remove a digraph.
>
> :dig! {char}{char} or :dig! {number} could be used to list digraphs
> matching certain criteria.

Is there any current Vim command that uses "!" to indicate that things
will be listed? If not, this seems even more inconsistent. "!" usually
means "watch out!" (because something will be deleted, e.g. :au!), or "I
really mean it!" (because some safety check is being removed, e.g.
:[range]w!, or :w! {existing-file}).

So, why not extend dig to take a first argument, the way :hi[light]
does, and add '!' to mean 'remove'? Ending up with something similar to
:au[tocmd]{,!}:

" lack of {number} means list
:dig " list all digraphs
:dig user " list user-defined digraphs
:dig {char}{char} " list digraph for {char}{char}

" specifying {number} means definition
:dig {char}{char} {number} " define digraph {char}{char} as {number}

" ! means delete, with same arguments as the "list" forms
:dig! " delete all digraphs
:dig! user " delete all user-defined digraphs
:dig! {char}{char} " delete the digraph for {char}{char}


" specifying {number} and ! means replace (delete and then define)
:dig! {char}{char} {number} " replace {char}{char} digraph w/ {number}

(The parallels with :au):
" lack of {cmd} means list (optionally limited to a group)
:au [group] " list all autocmds
:au [group] {event} " list all autocmds for event
:au [group] * {pat} " list autocmds for all events, w/pattern
:au [group] {event} {pat} " list autocmds for given event and pattern

" specifying {cmd} means definition (with optional 'nested' flag)
:au [group] {event} {pat} [nested] {cmd} " define an autocmd

" ! means delete (optionally limited to a group)
:au! [group] " delete all autocmds
:au! [group] {event} " delete all autocmds for event
:au! [group] * {pat} " delete autocmds for all events, w/pattern
:au! [group] {event} {pat} " delete autocmds for given event and pattern

" specifying {cmd} and ! means replace (delete and then define)
:au! [group] {event} {pat} [nested] {cmd}

To complete the similarities, the "user" argument could be thought of as
the digraphs' [group] (where the default group, if not specified, is
"all" when listing, and "user" when creating).

--
Best,
Ben

Marvin Renich

unread,
Apr 13, 2012, 6:27:35 PM4/13/12
to vim...@googlegroups.com
* Benjamin R. Haskell <v...@benizi.com> [120413 17:14]:

I agree that ! usually means "override a safety feature," but I don't
like it being used for delete; au! is the only example I can come up
with where :foo adds something and :foo! deletes it. I much, much
prefer :undig or :deldig. The analogy between the usage of :dig and :au
is tenuous at best; :dig is more closely related to :map or :ab, both of
which use :un prefix to delete.

While I think that :dig! would be a very poor choice for delete, I am
not at all set on using :dig! for listing. I would be just as happy to
use :ldig or something else for listing and leave :dig! undefined. :dig
with a single argument would be okay, but I have a mild preference for
something more explicit, which is why I extended the original suggestion
of using :dig!.

...Marvin

Christian Brabandt

unread,
Apr 14, 2012, 8:28:59 AM4/14/12
to vim...@googlegroups.com, vim-dev Mailingliste
Hi Bram!

On Fr, 13 Apr 2012, Bram Moolenaar wrote:

> Can we use another command to list user-defined digraphs? Perhaps
> ":dig ?"?
>
> This patch would also need documentation. And a test would be good too.

Updated patch.
The patch introduces the following changes:
1) :dig? print only user-defined digraphs
2) :dig? <char1>[<char2>] print an exact match, if 2 chars are given,
else print all digraphs matching char1
3) :dig? Number print digraph for decimal value Number
4) :dig! clear all user-defined digraphs
5) :dig! <char1><char2> clear user-defined digraph <char1><char2>
6) documentation update
7) including a test (test85)


regards,
Christian

digraphs.diff

Bram Moolenaar

unread,
Apr 14, 2012, 8:42:00 AM4/14/12
to Christian Brabandt, vim...@googlegroups.com, vim-dev Mailingliste

Christian Brabandt wrote:

Thanks for the quick update.

We don't use ? like this in any command, but somehow it feels right. Or
would there be something better?

":dig ? Number" is OK, but this looks like it only works for user
digraps. I suppose leaving out the ? has the problem that it would look
like defining a digraph, although ":dig 12" currently gives an error.
So perhaps we can use that.

--
WOMAN: Well, 'ow did you become king then?
ARTHUR: The Lady of the Lake, [angels sing] her arm clad in the purest
shimmering samite, held aloft Excalibur from the bosom of the water
signifying by Divine Providence that I, Arthur, was to carry
Excalibur. [singing stops] That is why I am your king!
The Quest for the Holy Grail (Monty Python)

Erik Falor

unread,
Apr 16, 2012, 11:32:10 AM4/16/12
to vim...@googlegroups.com
On Fri, Apr 13, 2012 at 05:09:37PM -0400, Benjamin R. Haskell wrote:
> On Fri, 13 Apr 2012, Marvin Renich wrote:

> Is there any current Vim command that uses "!" to indicate that things
> will be listed? If not, this seems even more inconsistent.

:files, (a.k.a. :buffers, a.k.a. :ls)

--
Erik Falor http://unnovative.net
Registered Linux User #445632 http://linuxcounter.net

Reply all
Reply to author
Forward
0 new messages