* Inserting standard text
@ 2007-04-26 9:19 anders
2007-04-26 13:05 ` B. T. Raven
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: anders @ 2007-04-26 9:19 UTC (permalink / raw)
To: help-gnu-emacs
Hi!
I have tryed to relace my development enviroment with Emacs, and i
have found it gives me
a lot of stuff i like.
Becurse i am new maby my question i simple, i have read a beginners
book but missing some.
I have debug text, that i tody in my old editor just press a key and
it insert this text.
Wha't is the easys way to do this, ELISP + KEYDEF or,,
I am develop in C under windows and compiling on a Solaris machine
any tips regarding whould be nice.
Thanks in advanced
Anders Persson
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Inserting standard text
2007-04-26 9:19 Inserting standard text anders
@ 2007-04-26 13:05 ` B. T. Raven
2007-04-26 19:28 ` james
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: B. T. Raven @ 2007-04-26 13:05 UTC (permalink / raw)
To: help-gnu-emacs
anders wrote:
> Hi!
> I have tryed to relace my development enviroment with Emacs, and i
> have found it gives me
> a lot of stuff i like.
>
> Becurse i am new maby my question i simple, i have read a beginners
> book but missing some.
>
> I have debug text, that i tody in my old editor just press a key and
> it insert this text.
>
> Wha't is the easys way to do this, ELISP + KEYDEF or,,
>
> I am develop in C under windows and compiling on a Solaris machine
> any tips regarding whould be nice.
>
> Thanks in advanced
>
> Anders Persson
>
If your question is just about Searching and Replacement, look under that
topic in the manual. In Emacs:
C-h i m
emacs
s
and the following block of command documents (Replacement Commands).
For info related to C mode see Editing Programs:
s
Editing Programs
I don't use Emacs for programming so I can't help if you are asking a more
exotic question. Maybe the policy of this ng would allow you to restate your
question in your native language.
If you study Emacs' built-in documentation diligently you will be able to
skip beginners' books and go right on to intermediate ones.
Ed
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Inserting standard text
2007-04-26 9:19 Inserting standard text anders
2007-04-26 13:05 ` B. T. Raven
@ 2007-04-26 19:28 ` james
2007-04-26 23:51 ` Tim X
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: james @ 2007-04-26 19:28 UTC (permalink / raw)
To: help-gnu-emacs
Google Groups has been brutally slow to update, so this may have been
answered already by people with real usenet providers.
If your needs are as simple as you imply, you could do something like:
(add-hook 'c-mode-common-hook
'(lambda ()
(local-set-key (kbd "<f7>")
'(lambda ()
(interactive)
(insert "#ifdef DEBUG\nprintf(\"TRACE:%s:%d\\n\",__FILE__,__LINE__);
\n#endif\n")))))
But for keyboard lightning I prefer msf-abbrev.el, which takes emacs'
built in support for abbrevs, and adds tabbing between fields, choice
lists, and executing elisp. To do something like the above, you
could set it up so that if you type "dx" then a space, it would expand
in place to the three lines in the insert statement above.
Check out the demo: http://www.bloomington.in.us/~brutt/msf-abbrev.html
jk
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Inserting standard text
2007-04-26 9:19 Inserting standard text anders
2007-04-26 13:05 ` B. T. Raven
2007-04-26 19:28 ` james
@ 2007-04-26 23:51 ` Tim X
2007-04-27 4:33 ` Drew Adams
2007-04-27 6:17 ` Maciej Katafiasz
2007-04-27 7:40 ` roodwriter
4 siblings, 1 reply; 7+ messages in thread
From: Tim X @ 2007-04-26 23:51 UTC (permalink / raw)
To: help-gnu-emacs
anders <anders.u.persson@gmail.com> writes:
> Hi!
> I have tryed to relace my development enviroment with Emacs, and i
> have found it gives me
> a lot of stuff i like.
>
> Becurse i am new maby my question i simple, i have read a beginners
> book but missing some.
>
> I have debug text, that i tody in my old editor just press a key and
> it insert this text.
>
> Wha't is the easys way to do this, ELISP + KEYDEF or,,
>
> I am develop in C under windows and compiling on a Solaris machine
> any tips regarding whould be nice.
>
Emacs comes with two packages which may meet your needs, plus there are a
number of add-on 'template' style packages out there.
The two standard packages are skeleton mode and tempo mode. Each allows varying
degrees of static and dynamic templates, which you can then bind to a key. For
example, I use this to put a standard template at the beginning of my code
files -
;;;
(tempo-define-template "generic-header"
'((format "%s" comment-start)
" Filename: " (buffer-file-name) 'n
(format "%s" comment-start) " Creation Date: "
(format-time-string "%A, %d %B %Y %I:%M %p %Z") 'n
(format "%s" comment-start) " Last Modified: " 'n
(format "%s" comment-start)
" Job: " (p "Job: ") 'n
(format "%s" comment-start)
" Author: Tim Cross <tcross@une.edu.au>"
'n
(format "%s" comment-start) " Description:" 'n
(format "%s" comment-start) 'n
'n))
I have this function bound to F6, so that I can insert it in a new file if
needed. The template contains the name of the file (and location) the date it
was created and a modified date that is automatically updated whenever the file
is saved. I've defined other templates for various languages that will setup
standard constructs in that language. Some of the templates, like the one
above, also prompts for information that is put into the template when it is
inserted.
If you don't want/need this level of flexibility or don't feel confident about
working with a bit of elisp, you can achieve a simple templating solution using
just a template file and creating either a named keyboard macro or function
that just inserts a template file into the current buffer.
You should also check out abbrevs. Many modes create 'electric' functions that
replace a bit of text with a simple template. For example, I think C mode uses
a combination of abbrev mode and skeleton mode so that while in that mode,
typeing 'if' can result in
if ( ! ) {
}
where ! indicates where the pointer/cursor will be after typing 'if'.
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Inserting standard text
2007-04-26 23:51 ` Tim X
@ 2007-04-27 4:33 ` Drew Adams
0 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2007-04-27 4:33 UTC (permalink / raw)
To: help-gnu-emacs
> > I have debug text, that i tody in my old editor just press a key and
> > it insert this text.
>
> Emacs comes with two packages which may meet your needs, plus there are a
> number of add-on 'template' style packages out there.
>
> The two standard packages are skeleton mode and tempo mode....For
> example, I use this to put a standard template at the beginning of my code
> files -
I don't know if it helps with what you want, but you might also look at
header2.el, which inserts and updates header text in a source file.
Library: http://www.emacswiki.org/cgi-bin/wiki/header2.el
Doc: http://www.emacswiki.org/cgi-bin/wiki/AutomaticFileHeaders
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Inserting standard text
2007-04-26 9:19 Inserting standard text anders
` (2 preceding siblings ...)
2007-04-26 23:51 ` Tim X
@ 2007-04-27 6:17 ` Maciej Katafiasz
2007-04-27 7:40 ` roodwriter
4 siblings, 0 replies; 7+ messages in thread
From: Maciej Katafiasz @ 2007-04-27 6:17 UTC (permalink / raw)
To: help-gnu-emacs
Den Thu, 26 Apr 2007 02:19:37 -0700 skrev anders:
> I have debug text, that i tody in my old editor just press a key and
> it insert this text.
>
> Wha't is the easys way to do this, ELISP + KEYDEF or,,
See http://www.emacswiki.org/cgi-bin/wiki/CategoryTemplates . I just
started using msf-abbrev, it's particularly notable for having the easiest
syntax of all, making it possible to add new snippets without careful
programming, and also very nice navigation within the inserted text.
See http://www.bloomington.in.us/~brutt/msf-abbrev-demo.gif , you should
be able to tell if it fits your purposes from that.
Cheers,
Maciej
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Inserting standard text
2007-04-26 9:19 Inserting standard text anders
` (3 preceding siblings ...)
2007-04-27 6:17 ` Maciej Katafiasz
@ 2007-04-27 7:40 ` roodwriter
4 siblings, 0 replies; 7+ messages in thread
From: roodwriter @ 2007-04-27 7:40 UTC (permalink / raw)
To: help-gnu-emacs
anders <anders.u.persson@gmail.com> writes:
> Hi!
> I have tryed to relace my development enviroment with Emacs, and i
> have found it gives me
> a lot of stuff i like.
>
> Becurse i am new maby my question i simple, i have read a beginners
> book but missing some.
>
> I have debug text, that i tody in my old editor just press a key and
> it insert this text.
>
> Wha't is the easys way to do this, ELISP + KEYDEF or,,
>
> I am develop in C under windows and compiling on a Solaris machine
> any tips regarding whould be nice.
>
> Thanks in advanced
>
> Anders Persson
>
Being a writer, not a programmer, I do something as low-tech as a
macro incorporating an insert-file function calling up a file with the
appropriate text or template. For short stuff I have some abbrevs set
up.
There are all kinds of ways to do things with Emacs.
--Rod
______________________
Author of "Linux for Non-Geeks--Clear-eyed Answers for Practical
Consumers" and "Boring Stories from Uncle Rod." To reply by e-mail
take the second "o" out of the e-mail address.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-04-27 7:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-26 9:19 Inserting standard text anders
2007-04-26 13:05 ` B. T. Raven
2007-04-26 19:28 ` james
2007-04-26 23:51 ` Tim X
2007-04-27 4:33 ` Drew Adams
2007-04-27 6:17 ` Maciej Katafiasz
2007-04-27 7:40 ` roodwriter
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).