help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dabbrev problem...


From: cons
Subject: Re: dabbrev problem...
Date: Fri, 14 Sep 2007 05:39:38 -0700
User-agent: G2/1.0

On 14 Sep, 12:20, Andreas Röhler <andreas.roeh...@online.de> wrote:
> Am Donnerstag, 13. September 2007 21:51 schrieb cons:
>
> > (defun complete-further (arg)
> >   "Insert space if necessary and then call dabbrev-expand."
> >   (interactive "*P")
> >   (if (not (eq (preceding-char) ?\s))
> >                 (insert ?\s))
> >   (dabbrev-expand arg))
>
> What about this:
>
> (defun dabbrev-expand-before-point (arg)
>   (interactive "*p")
>     (skip-chars-backward " \t\r\n\f")
>     (dabbrev-expand arg)
>   (unless (eq (preceding-char) ?\ )
>     (insert " ")))
>
> Andreas Röhler

Hmmm, that does not work. Let me explain. The manual describes it as
"After you have expanded a dynamic abbrev, you can copy additional
words that follow the expansion in its original context. Simply type
<SPC> M-/ for each additional word you want to copy. The spacing and
punctuation between words is copied along with the words." For
example, put the point at the end of the string
"demonstration,of,dabbrevs,extend-word,feature. dem". Now press M-/.
The word 'dem' is now expanded to the word 'demonstration'. Now press
SPC and then M-/ again. Dabbev-expand now deletes the space you just
wrote and replace it with the next word. The result is
"demonstration,of". Press SPC and M-/ again and you get
"demonstration,of,dabbrevs" and so on. The pattern here is to press
M-/ SPC M-/ SPC M-/ SPC M-/ etc for each word you want to expand.

Now, instead of for example pressing M-/ SPC M-/ SPC M-/ (5 key
presses), I would instead like to just press something like M-/ F1 F1
(3 key presses). This of course requires that I bind a new function to
F1 that simply first insert a SPC and then call dabbrev-expand:

(defun complete-further (arg)
  "Insert space and then call dabbrev-expand."
  (interactive "*P")
  (insert " ")
  (dabbrev-expand arg))

but that doesn't work for some strange reason. In the example above
M-/ results in the correct 'demonstration'. The first press of F1 also
works and result in "demonstration,of" as expected. But the second
press of F1 that should result in 'demonstration,of,dabbrevs' totally
freaks out and produce a random result.

The function you provided doesn't work either unfortunately. Does
somebody know what's going on? Why isn't it equivalent to press SPC
M-/ and let a function inserts a SPC and then call dabbrev-expand?

/Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]