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

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

Re: capitalised in 'abbrev_defs'?


From: Sharon Kimble
Subject: Re: capitalised in 'abbrev_defs'?
Date: Thu, 27 Jul 2017 11:06:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Emanuel Berg <moasen@zoho.com> writes:

> Sharon Kimble wrote:
>
>> Whenever I save a new addition to
>> 'abbrev_defs' that is capitalised it is
>> *always* saved in lower case. How do I get it
>> to save as capitalised please?
>
> See ‘:case-fixed’ in
>
>     (info "(elisp) Abbrev Properties")
>
> The reason this isn't there by default is to
> have a more (?) intelligent system that will
> capitalize the abbrev expansion differently for
> the same abbrev input, depending on the
> capitalization of the input.

Okay, thanks for this.

This is my main block of code that initialises abbrev_defs -

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
;; (setq abbrev-file-name (concat *my-emacs-lib-dir* "abbrev_defs.el"))
; I define *my-emacs-lib-dir* in my .emacs; see that section for details
    ;; (setq abbrev-file-name (locate-user-emacs-file "abbrev_defs"))
    ;; (unless (file-exists-p abbrev-file-name)
    ;;   (with-temp-buffer (write-file abbrev-file-name)))

(setq abbrev-file-name             ;; tell emacs where to read abbrev
        "/home/boudiccas/.emacs.d/abbrev_defs")    ;; definitions from...

;; (setq abbrev-file-name ("abbrev_defs"))
    (defconst modi/abbrev-hooks '(verilog-mode-hook
                                  emacs-lisp-mode-hook
                                  org-mode-hook)
      "List of hooks of major modes in which abbrev should be enabled.")

    (defun modi/turn-on-abbrev-mode ()
      "Turn on abbrev only for specific modes."
      (interactive)
      (dolist (hook modi/abbrev-hooks)
        (add-hook hook #'abbrev-mode)))

    (defun modi/turn-off-abbrev-mode ()
      "Turn off abbrev only for specific modes."
      (interactive)
      (dolist (hook modi/abbrev-hooks)
        (remove-hook hook #'abbrev-mode)))

    (setq save-abbrevs 'silently) ; silently save abbrevs on quitting emacs

    (modi/turn-on-abbrev-mode)
    (quietly-read-abbrev-file) ; reads the abbreviations file on startup


(read-abbrev-file abbrev-file-name t)
(setq dabbrev-case-replace nil)  ; Preserve case when expanding
(setq abbrev-mode t)
#+end_src
[2015-12-22 Tue 10:27]
[2015-12-26 Sat 05:37]
[2017-01-17 Tue 10:38]

heavily influenced by kaushalmodi
--8<---------------cut here---------------end--------------->8---

And this is my main block of code which uses abbrev_defs -

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
(define-key ctl-x-map "\C-i"
  #'endless/ispell-word-then-abbrev)

(defun endless/ispell-word-then-abbrev (p)
  "Call `ispell-word', then create an abbrev for it.
With prefix P, create local abbrev. Otherwise it will
be global.
If there's nothing wrong with the word at point, keep
looking for a typo until the beginning of buffer. You can
skip typos you don't want to fix with `SPC', and you can
abort completely with `C-g'."
  (interactive "P")
  (let (bef aft)
    (save-excursion
      (while (if (setq bef (thing-at-point 'word))
                 ;; Word was corrected or used quit.
                 (if (ispell-word nil 'quiet)
                     nil ; End the loop.
                   ;; Also end if we reach `bob'.
                   (not (bobp)))
               ;; If there's no word at point, keep looking
               ;; until `bob'.
               (not (bobp)))
        (backward-word))
      (setq aft (thing-at-point 'word)))
    (if (and aft bef (not (equal aft bef)))
        (let ((aft (downcase aft))
              (bef (downcase bef)))
          (define-abbrev
            (if p local-abbrev-table global-abbrev-table)
            bef aft)
          (message "\"%s\" now expands to \"%s\" %sally"
                   bef aft (if p "loc" "glob")))
      (user-error "No typo at or before point"))))

(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)
#+end_src
[2016-02-14 Sun 18:15]
[2017-01-17 Tue 13:37]

http://endlessparentheses.com/ispell-and-abbrev-the-perfect-auto-correct.html
--8<---------------cut here---------------end--------------->8---

So how do I 'turn on' case-fixed please? Would it be something like -

--8<---------------cut here---------------start------------->8---
(setq abbrev-mode case-fixed t)
--8<---------------cut here---------------end--------------->8---

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 9.0, fluxbox 1.3.5-2, emacs 25.1.1, org-mode 9.0.9

Attachment: signature.asc
Description: PGP signature


reply via email to

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