* Short to long form expansion? @ 2006-02-21 19:27 Christopher Campbell 2006-02-23 15:44 ` Stefan Monnier ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Christopher Campbell @ 2006-02-21 19:27 UTC (permalink / raw) Hi, Is there a mode that allows completion of words by taking a short form, and comparing it with text in the buffer to deduce a longer form? e.g. in a buffer with complete_text some-variable-name c_t M-RET -> complete_text s-v-n M-RET -> some-variable-name Anything like that? I use pabbrev-mode which helps alot with code editing, but this little extra would be icing on the cake. Cheers, Chris Campbell ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Short to long form expansion? 2006-02-21 19:27 Short to long form expansion? Christopher Campbell @ 2006-02-23 15:44 ` Stefan Monnier 2006-02-23 22:08 ` Christopher Campbell 2006-02-24 22:04 ` Drew Adams 2006-02-23 22:07 ` Kevin Rodgers [not found] ` <mailman.39.1140848322.5016.help-gnu-emacs@gnu.org> 2 siblings, 2 replies; 6+ messages in thread From: Stefan Monnier @ 2006-02-23 15:44 UTC (permalink / raw) > Is there a mode that allows completion of words by taking a short form, and > comparing it with text in the buffer to deduce a longer form? e.g. > in a buffer with > complete_text > some-variable-name > c_t M-RET -> complete_text > s-v-n M-RET -> some-variable-name > Anything like that? I use pabbrev-mode which helps alot with code editing, > but this little extra would be icing on the cake. I use dabbrev for that, with the following patch, Stefan --- orig/lisp/dabbrev.el +++ mod/lisp/dabbrev.el @@ -958,10 +958,12 @@ Returns the expansion found, or nil if not found. Leaves point at the location of the start of the expansion." (save-match-data - (let ((pattern1 (concat (regexp-quote abbrev) - "\\(" dabbrev--abbrev-char-regexp "\\)")) - (pattern2 (concat (regexp-quote abbrev) - "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) + (let ((pattern1 (concat (mapconcat (lambda (c) (regexp-quote (string c))) + abbrev (concat "\\(?:" dabbrev--abbrev-char-regexp "\\)*")) + "\\(?:" dabbrev--abbrev-char-regexp "\\)")) + (pattern2 (concat (mapconcat (lambda (c) (regexp-quote (string c))) + abbrev (concat "\\(?:" dabbrev--abbrev-char-regexp "\\)*")) + "\\(\\(?:" dabbrev--abbrev-char-regexp "\\)+\\)")) ;; This makes it possible to find matches in minibuffer prompts ;; even when they are "inviolable". (inhibit-point-motion-hooks t) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Short to long form expansion? 2006-02-23 15:44 ` Stefan Monnier @ 2006-02-23 22:08 ` Christopher Campbell 2006-02-24 22:04 ` Drew Adams 1 sibling, 0 replies; 6+ messages in thread From: Christopher Campbell @ 2006-02-23 22:08 UTC (permalink / raw) Stefan Monnier wrote: >> Anything like that? I use pabbrev-mode which helps alot with code editing, >> but this little extra would be icing on the cake. > > I use dabbrev for that, with the following patch, Thanks, I'll give it ago. ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Short to long form expansion? 2006-02-23 15:44 ` Stefan Monnier 2006-02-23 22:08 ` Christopher Campbell @ 2006-02-24 22:04 ` Drew Adams 1 sibling, 0 replies; 6+ messages in thread From: Drew Adams @ 2006-02-24 22:04 UTC (permalink / raw) > Is there a mode that allows completion of words by taking a > short form, and comparing it with text in the buffer to > deduce a longer form? e.g. in a buffer with complete_text > some-variable-name c_t M-RET -> complete_text > s-v-n M-RET -> some-variable-name Anything like that? > I use pabbrev-mode which helps alot with code editing, > but this little extra would be icing on the cake. I use dabbrev for that, with the following patch... You might also be interested in `icicles.el', which enhances `dabbrev.el' by providing `dabbrev-completion' (bound to `M-C-/') with cycling of completion candidates (in addition to completion). It also lets you complete using a regexp and provides some other features. http://www.emacswiki.org/cgi-bin/emacs/icicles.el ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Short to long form expansion? 2006-02-21 19:27 Short to long form expansion? Christopher Campbell 2006-02-23 15:44 ` Stefan Monnier @ 2006-02-23 22:07 ` Kevin Rodgers [not found] ` <mailman.39.1140848322.5016.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 6+ messages in thread From: Kevin Rodgers @ 2006-02-23 22:07 UTC (permalink / raw) Christopher Campbell wrote: > Is there a mode that allows completion of words by taking a short form, > and comparing it with text in the buffer to deduce a longer form? e.g. > > in a buffer with > > complete_text > some-variable-name > > c_t M-RET -> complete_text > s-v-n M-RET -> some-variable-name > > Anything like that? I use pabbrev-mode which helps alot with code > editing, but this little extra would be icing on the cake. I don't know -- what is pabbrev-mode? It sounds to me like what you want is a combination of Dynamic Abbrev mode and Partial Completion mode. What happens if you turn on both? ,---- | The abbrev facility described above operates automatically as you | insert text, but all abbrevs must be defined explicitly. By contrast, | "dynamic abbrevs" allow the meanings of abbrevs to be determined | automatically from the contents of the buffer, but dynamic abbrev | expansion happens only when you request it explicitly. | | `M-/' | Expand the word in the buffer before point as a "dynamic abbrev", | by searching in the buffer for words starting with that | abbreviation (`dabbrev-expand'). | | `C-M-/' | Complete the word before point as a dynamic abbrev | (`dabbrev-completion'). | | For example, if the buffer contains `does this follow ' and you type | `f o M-/', the effect is to insert `follow' because that is the last | word in the buffer that starts with `fo'. A numeric argument to `M-/' | says to take the second, third, etc. distinct expansion found looking | backward from point. Repeating `M-/' searches for an alternative | expansion by looking farther back. After scanning all the text before | point, it searches the text after point. The variable `dabbrev-limit', | if non-`nil', specifies how far in the buffer to search for an | expansion. | ... | The command `C-M-/' (`dabbrev-completion') performs completion of a | dynamic abbreviation. Instead of trying the possible expansions one by | one, it finds all of them, then inserts the text that they have in | common. If they have nothing in common, `C-M-/' displays a list of | completions, from which you can select a choice in the usual manner. | *Note Completion::. `---- ,---- | Partial Completion mode implements a more powerful kind of | completion that can complete multiple words in parallel. For example, | it can complete the command name abbreviation `p-b' into | `print-buffer', because no other command starts with two words whose | initials are `p' and `b'. | | Partial completion of directories in file names uses `*' to indicate | the places for completion; thus, `/u*/b*/f*' might complete to | `/usr/bin/foo'. | | To enable this mode, use the command `M-x partial-completion-mode', | or customize the option `partial-completion-mode'. This binds the | partial completion commands to <TAB>, <SPC>, <RET>, and `?'. The usual | completion commands are available on `M-<TAB>', `M-<SPC>', `M-<RET>' | and `M-?'. `---- -- Kevin Rodgers ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.39.1140848322.5016.help-gnu-emacs@gnu.org>]
* Re: Short to long form expansion? [not found] ` <mailman.39.1140848322.5016.help-gnu-emacs@gnu.org> @ 2006-02-27 18:37 ` Christopher Campbell 0 siblings, 0 replies; 6+ messages in thread From: Christopher Campbell @ 2006-02-27 18:37 UTC (permalink / raw) Kevin Rodgers wrote: > Christopher Campbell wrote: > > Is there a mode that allows completion of words by taking a short form, > > and comparing it with text in the buffer to deduce a longer form? e.g. > > > > in a buffer with > > > > complete_text > > some-variable-name > > > > c_t M-RET -> complete_text > > s-v-n M-RET -> some-variable-name > > > > Anything like that? I use pabbrev-mode which helps alot with code > > editing, but this little extra would be icing on the cake. > > I don't know -- what is pabbrev-mode? It sounds to me like what you > want is a combination of Dynamic Abbrev mode and Partial Completion > mode. What happens if you turn on both? Pabbrev is like Dabbrev only it is as you type. Partial completion mode only seems to work for minibuffer, not in the main buffer. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-02-27 18:37 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-02-21 19:27 Short to long form expansion? Christopher Campbell 2006-02-23 15:44 ` Stefan Monnier 2006-02-23 22:08 ` Christopher Campbell 2006-02-24 22:04 ` Drew Adams 2006-02-23 22:07 ` Kevin Rodgers [not found] ` <mailman.39.1140848322.5016.help-gnu-emacs@gnu.org> 2006-02-27 18:37 ` Christopher Campbell
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).