From: Sharon Kimble <boudiccas@skimble.plus.com>
To: help-gnu-emacs@gnu.org
Subject: Re: capitalised in 'abbrev_defs'?
Date: Thu, 27 Jul 2017 11:06:04 +0100 [thread overview]
Message-ID: <87h8xyqjn7.fsf@skimble.plus.com> (raw)
In-Reply-To: <86eft2s3c0.fsf@zoho.com> (Emanuel Berg's message of "Thu, 27 Jul 2017 10:15:27 +0200")
[-- Attachment #1: Type: text/plain, Size: 4598 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2017-07-27 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-27 7:37 capitalised in 'abbrev_defs'? Sharon Kimble
2017-07-27 8:15 ` Emanuel Berg
2017-07-27 10:06 ` Sharon Kimble [this message]
2017-07-27 12:43 ` Kaushal Modi
2017-07-27 15:10 ` Emanuel Berg
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h8xyqjn7.fsf@skimble.plus.com \
--to=boudiccas@skimble.plus.com \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.