[Top][All Lists]

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


From: Andreas Roehler
Subject: add-abbrev-propose-initials
Date: Wed, 30 May 2007 14:19:17 +0200
User-agent: Thunderbird (X11/20070221)

Maybe someone takes interest in it.


Andreas Roehler

(defun add-abbrev-propose-initials (table type arg)
 "A (slightly) extended add-abbrev function:
if more than one word shall be abbreviated
it takes the initials of these words
constructing an abbrev proposal from it."
 (let* ((exp (and (>= arg 0)
           (if (= arg 0) (mark)
             (save-excursion (forward-word (- arg)) (point))))))
    (prepare (split-string exp))
    propose name)
   (when (< 1 (abs arg))
     (dolist (elt prepare)
   (setq propose (concat propose (downcase (substring elt 0 1)))))
     (message "%s" propose))
   (setq name
     (read-string (format (if exp "%s abbrev for \"%s\": "
                "Undefine %s abbrev: ")
                  type exp)
              propose t propose))
   (set-text-properties 0 (length name) nil name)
   (if (or (null exp)
       (not (abbrev-expansion name table))
       (y-or-n-p (format "%s expands to \"%s\"; redefine? "
                 name (abbrev-expansion name table))))
   (define-abbrev table (downcase name) exp))))

;; end

reply via email to

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