* Using skeletons: how to avoid adding newline?
@ 2003-04-13 6:43 Karl Eichwalder
2003-04-13 9:18 ` Oliver Scholz
0 siblings, 1 reply; 4+ messages in thread
From: Karl Eichwalder @ 2003-04-13 6:43 UTC (permalink / raw)
I'm trying to accomplish something very basic: "link" should become
[[link]]; this code snippet works but I'd like to avoid the newline
after "]]":
(define-skeleton ke-wp-make-link
"Create [[wikipedia link]]."
nil
"[[" _ "]]")
(global-set-key "\C-c[" 'ke-wp-make-link)
This is what I do:
1. Enter ("-!-" [[marks]]
the point):
Create -!-link here
2. Press "C-SPC" and "M-f" to mark a region:
Create link-!- here
3. Press "C-c [" to add [[...]]:
=>
Create [[link]]
-!- here
But I want to see:
Create [[link]]-!- here
--
ke@suse.de (work) / keichwa@gmx.net (home): |
http://www.gnu.franken.de/ke/ | ,__o
Free Translation Project: | _-\_<,
http://www.iro.umontreal.ca/contrib/po/HTML/ | (*)/'(*)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using skeletons: how to avoid adding newline?
2003-04-13 6:43 Using skeletons: how to avoid adding newline? Karl Eichwalder
@ 2003-04-13 9:18 ` Oliver Scholz
2003-04-13 15:15 ` Karl Eichwalder
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Scholz @ 2003-04-13 9:18 UTC (permalink / raw)
Karl Eichwalder <keichwa@gmx.net> writes:
> I'm trying to accomplish something very basic: "link" should become
> [[link]]; this code snippet works but I'd like to avoid the newline
> after "]]":
>
> (define-skeleton ke-wp-make-link
> "Create [[wikipedia link]]."
> nil
> "[[" _ "]]")
Looking at the code of skeleton.el ... this happens because
`skeleton-end-hook' is run after the insertion.
,----[ C-h v skeleton-end-hook RET ]
| [...]
|
| Hook called at end of skeleton but before going to point of interest.
| By default this moves out anything following to next line,
| unless `skeleton-end-newline' is set to nil.
| The variables `v1' and `v2' are still set when calling this.
|
| Defined in `skeleton'.
|
| [back]
`----
Setting `skeleton-end-newline' to nil, does help indeed. But I have
no idea whether this causes trouble elsewhere. Perhaps it is best to
set it buffer locally?
Oliver
--
24 Germinal an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using skeletons: how to avoid adding newline?
2003-04-13 9:18 ` Oliver Scholz
@ 2003-04-13 15:15 ` Karl Eichwalder
2003-04-13 17:04 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Karl Eichwalder @ 2003-04-13 15:15 UTC (permalink / raw)
Oliver Scholz <alkibiades@gmx.de> writes:
> Looking at the code of skeleton.el ... this happens because
> `skeleton-end-hook' is run after the insertion.
Thanks for the hint; this seems to do the trick:
(defun ke-wp-make-link ()
"Create [[wikipedia link]]."
(interactive "*")
(let ((skeleton-end-newline nil))
(if mark-active
(skeleton-insert '(nil
"[[" _ "]]")
-1)
(skeleton-insert '(nil
"[[" _ "]]")))))
(global-set-key "\C-c[" 'ke-wp-make-link)
Maybe it's worth to add this information to
http://www.emacswiki.org/cgi-bin/wiki.pl?SkeletonMode
> Setting `skeleton-end-newline' to nil, does help indeed. But I have
> no idea whether this causes trouble elsewhere. Perhaps it is best to
> set it buffer locally?
Yes, this looks like a good idea. Wondering why the default isn't
nil?
--
ke@suse.de (work) / keichwa@gmx.net (home): |
http://www.gnu.franken.de/ke/ | ,__o
Free Translation Project: | _-\_<,
http://www.iro.umontreal.ca/contrib/po/HTML/ | (*)/'(*)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using skeletons: how to avoid adding newline?
2003-04-13 15:15 ` Karl Eichwalder
@ 2003-04-13 17:04 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2003-04-13 17:04 UTC (permalink / raw)
>> Setting `skeleton-end-newline' to nil, does help indeed. But I have
>> no idea whether this causes trouble elsewhere. Perhaps it is best to
>> set it buffer locally?
> Yes, this looks like a good idea. Wondering why the default isn't
> nil?
I also wonder and wish I could change it.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-04-13 17:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-13 6:43 Using skeletons: how to avoid adding newline? Karl Eichwalder
2003-04-13 9:18 ` Oliver Scholz
2003-04-13 15:15 ` Karl Eichwalder
2003-04-13 17:04 ` Stefan Monnier
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).