unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: lost my abbrev-defs file
Date: Mon, 26 Apr 2010 14:00:02 +0200	[thread overview]
Message-ID: <4BD58042.1030500@easy-emacs.de> (raw)
In-Reply-To: <u2of22f52181004251958zcdd174f5p83064d83060ea0cf@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

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
> 
> 
> 

Hi,

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 expansion.

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...

HTH


Andreas

--
https://code.launchpad.net/~a-roehler/python-mode
https://code.launchpad.net/s-x-emacs-werkstatt/



[-- Attachment #2: mode-abbrev-propose.el --]
[-- Type: text/x-emacs-lisp, Size: 3433 bytes --]

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

;; for all Emacsen

;; Author: Andreas Roehler;;  <andreas.roehler@online.de>
;; 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
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; 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) 
  (save-excursion 
    (let ((exp (and (>= arg 0)
                    (buffer-substring-no-properties
                     (point)
                     (if (= arg 0) (mark)
                       (save-excursion (forward-word (- arg))
                                       (when (and
                                              (eq (char-before) 40)
                                              (eq major-mode 'emacs-lisp-mode))
                                         (forward-char -1))
                                       (point))))))
          proposal 
          name)
      (when (and (featurep 'xemacs)(eq major-mode 'emacs-lisp-mode))
        ;; (when (eq major-mode 'emacs-lisp-mode)
        (setq exp (concat "(" exp)))
      (save-excursion
        (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
                proposal
              (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")
  (save-excursion 
    (add-abbrev-propose
     (if only-global-abbrevs
         global-abbrev-table
       (or local-abbrev-table
           (error "No per-mode abbrev table")))
   "Mode" arg)))

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




      parent reply	other threads:[~2010-04-26 12:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-26  2:58 lost my abbrev-defs file Matt Price
2010-04-26  5:28 ` filebat Mark
2010-04-26 12:00 ` Andreas Röhler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BD58042.1030500@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).