[Top][All Lists]

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

Re: lost my abbrev-defs file

From: Andreas Röhler
Subject: Re: lost my abbrev-defs file
Date: Mon, 26 Apr 2010 14:00:02 +0200
User-agent: Thunderbird (X11/20081227)

Matt Price wrote:
> after cultivating my abbrev_defs file for months i seem to have
> accidentqally overwritten it with a blank one -- it's heartbreaking!
> so, having learned the importance of backups, or in this case maybe
> version control, i'm wondering whether anyone out there has a nice
> long abbrev_defs file with their commonly-mistyped English-language
> words -- or if you know a place on the web i can find one.  for
> instance, notice that i'm typing 'i' in lowercase -- because i'm used
> to having abbrev-mode correct it for me!  anyway, if anyone cal help
> i'd sure appreciate it.  thanks much,
> matt


sorry, don't have that much english abbrevs, as german native speaking.

Maybe there is some help though:
attached mode-abbrev-propose.el makes defining of an mode-abbrev much faster:
it takes a numerical argument - how many words before point being part of the 

Finally it offers the downcased first chars of these words as abbrev.

Quite often it's just RET than to store it.

Here some examples:

    ("atm" "at the moment" nil 0)
    ("atos" "At the other side" nil 0)
    ("belrin" "Berlin" nil 1)
    ("ec" "Emample code" nil 1)

Should you need german abbrevs, could deliver some more...




;;; mode-abbrev-propose.el --- initial content for mode-abbrevs

;; for all Emacsen

;; Author: Andreas Roehler;;  <>
;; Keywords: abbrev

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; A slightly modified `add-mode-abbrev' providing a
;; proposal for new abbrevs. Proposal is composed from
;; the initial character(s) of the expansion.

;;; Code:

(defun add-abbrev-propose (table type arg &optional dont-ask) 
    (let ((exp (and (>= arg 0)
                     (if (= arg 0) (mark)
                       (save-excursion (forward-word (- arg))
                                       (when (and
                                              (eq (char-before) 40)
                                              (eq major-mode 'emacs-lisp-mode))
                                         (forward-char -1))
      (when (and (featurep 'xemacs)(eq major-mode 'emacs-lisp-mode))
        ;; (when (eq major-mode 'emacs-lisp-mode)
        (setq exp (concat "(" exp)))
        (while (< 0 arg)
          (forward-word -1)
          (setq proposal (concat (downcase (buffer-substring-no-properties 
(point) (1+ (point)))) proposal))
          (setq arg (1- arg)))) 
      (setq name
            ;; ask only when interactive
            (if dont-ask
              (read-string (format (if exp "%s abbrev for \"%s\": "
                                     "Undefine %s abbrev: ")
                                   type exp) proposal)))
      (set-text-properties 0 (length name) nil name)
      (when (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
          ;; (replace-regexp-in-string "\n" " " exp)

(defun add-mode-abbrev-propose (arg) 
  "Define mode-specific abbrev for last word(s) before point.
Argument is how many words before point form the expansion;
or zero means the region is the expansion.
A negative argument means to undefine the specified abbrev.
Reads the abbreviation in the minibuffer.
Don't use this function in a Lisp program; use `define-abbrev' instead."
  (interactive "p")
     (if only-global-abbrevs
       (or local-abbrev-table
           (error "No per-mode abbrev table")))
   "Mode" arg)))

(provide 'mode-abbrev-propose)
;;; mode-abbrev-propose.el ends here

reply via email to

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