all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dabbrev problem...
@ 2007-09-13 19:51 cons
  2007-09-14 10:20 ` Andreas Röhler
       [not found] ` <mailman.853.1189765115.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: cons @ 2007-09-13 19:51 UTC (permalink / raw)
  To: help-gnu-emacs

I really like and use the dabbrev feature of copying the following
words with SPC M-/ SPC M-/ ... etc. So much infact that I want to do a
command that saves me that extra SPC-press. Basically, the command
should just execute 'dabbrev-expand' if there is a SPC before point,
or else insert a SPC and then execute 'dabbrev-expand':

(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))

The only problem is that it ain't working :(

What am I doing wrong?

Best regards,

/Stefan

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

* Re: dabbrev problem...
  2007-09-13 19:51 dabbrev problem cons
@ 2007-09-14 10:20 ` Andreas Röhler
       [not found] ` <mailman.853.1189765115.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Röhler @ 2007-09-14 10:20 UTC (permalink / raw)
  To: help-gnu-emacs

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

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

* Re: dabbrev problem...
       [not found] ` <mailman.853.1189765115.18990.help-gnu-emacs@gnu.org>
@ 2007-09-14 12:39   ` cons
  2007-09-14 14:24     ` Andreas Röhler
       [not found]     ` <mailman.871.1189779748.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: cons @ 2007-09-14 12:39 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 2419 bytes --]

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

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

* Re: dabbrev problem...
  2007-09-14 12:39   ` cons
@ 2007-09-14 14:24     ` Andreas Röhler
       [not found]     ` <mailman.871.1189779748.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Röhler @ 2007-09-14 14:24 UTC (permalink / raw)
  To: help-gnu-emacs

Am Freitag, 14. September 2007 14:39 schrieb cons:
> (defun complete-further (arg)
>   "Insert space and then call dabbrev-expand."
>   (interactive "*P")
>   (insert " ")
>   (dabbrev-expand arg))

Just take a lesser "p" and it will do.

  (interactive "*p")

Andreas Röhler

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

* Re: dabbrev problem...
       [not found]     ` <mailman.871.1189779748.18990.help-gnu-emacs@gnu.org>
@ 2007-09-14 20:12       ` cons
  0 siblings, 0 replies; 5+ messages in thread
From: cons @ 2007-09-14 20:12 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 495 bytes --]

On 14 Sep, 16:24, Andreas Röhler <andreas.roeh...@online.de> wrote:
> Am Freitag, 14. September 2007 14:39 schrieb cons:
>
> > (defun complete-further (arg)
> >   "Insert space and then call dabbrev-expand."
> >   (interactive "*P")
> >   (insert " ")
> >   (dabbrev-expand arg))
>
> Just take a lesser "p" and it will do.
>
>   (interactive "*p")
>
> Andreas Röhler

Thanks a million! Now it works perfectly! Must learn the meaning of
'interactive' apparently... :)

/Stefan

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

end of thread, other threads:[~2007-09-14 20:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-13 19:51 dabbrev problem cons
2007-09-14 10:20 ` Andreas Röhler
     [not found] ` <mailman.853.1189765115.18990.help-gnu-emacs@gnu.org>
2007-09-14 12:39   ` cons
2007-09-14 14:24     ` Andreas Röhler
     [not found]     ` <mailman.871.1189779748.18990.help-gnu-emacs@gnu.org>
2007-09-14 20:12       ` cons

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.