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

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

Re: boilerplate expansion module?


From: Pascal Bourguignon
Subject: Re: boilerplate expansion module?
Date: 15 May 2003 00:10:32 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Ignoramus13246 <ignoramus13246@NOSPAM.13246.invalid> writes:

> I am looking for some extension that would let me insert boilerplate
> text. For example. Let's say that I have a legal disclaimer saying
> "author is not responsible for errors and omissions". And instead of
> typing it, I would define boilerplate phrase "discl1" to be "author is
> not responsible for errors and omissions". Then as I type text, I
> would enter discl1, press some key like M-M-b, and it would replace
> discl1 with the actual phrase.
> 
> Any suggestions?
> 
> I use xemacs btw.
> 
> i

Untested code follows:

(defvar *boiler-plate-dir* "~/boiler-plates"
  "The directory where the boiler plates are stored.")

(defun insert-boiler-plate ()
  (interactive "*")
  (let* ((start (progn (backward-word) (point)))
         (end   (progn (forward-word)  (point)))
         (name (buffer-substring-no-properties start end))
         (fname (concat *boiler-plate-dir* "/" name ".txt")))
    (unless (file-exists-p fname)
      (error "Unknown boiler plate %S" name))      
    (delete-region start end)
    (insert-file fname)))

(global-set-key "M-M-b" 'insert-boiler-plate)


Personnaly, I  find that it  would be better  to type first  M-M-b (or
whatever) then  have in the  minibuffer a completion on  the available
boiler plates, but here you have what you asked.

-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.


reply via email to

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