On Fri, 13 Apr 2012, Marvin Renich wrote:

* Bram Moolenaar <b...@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

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui