From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Sharon Kimble Newsgroups: gmane.emacs.help Subject: Re: capitalised in 'abbrev_defs'? Date: Thu, 27 Jul 2017 11:06:04 +0100 Message-ID: <87h8xyqjn7.fsf@skimble.plus.com> References: <87r2x2qqj4.fsf@skimble.plus.com> <86eft2s3c0.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1501150014 13314 195.159.176.226 (27 Jul 2017 10:06:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 27 Jul 2017 10:06:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 27 12:06:47 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dafgq-0002um-1w for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jul 2017 12:06:44 +0200 Original-Received: from localhost ([::1]:42079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dafgv-00071r-Nw for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jul 2017 06:06:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dafgT-00071Y-6u for help-gnu-emacs@gnu.org; Thu, 27 Jul 2017 06:06:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dafgO-0006lt-Nl for help-gnu-emacs@gnu.org; Thu, 27 Jul 2017 06:06:21 -0400 Original-Received: from avasout08.plus.net ([212.159.14.20]:39277) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dafgO-0006iK-DK for help-gnu-emacs@gnu.org; Thu, 27 Jul 2017 06:06:16 -0400 Original-Received: from London.london ([31.185.147.16]) by avasout08 with smtp id pm6B1v0040MTadK01m6C1F; Thu, 27 Jul 2017 11:06:12 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=FLJr/6gs c=1 sm=1 tr=0 a=ljAp/NMcg50riqJ2O12TGw==:117 a=ljAp/NMcg50riqJ2O12TGw==:17 a=jKjxfLc-AAAA:8 a=0dxUO2ygAAAA:8 a=LlzXLoV6AAAA:8 a=iI7HsYTVAAAA:8 a=bAHfVwKlAAAA:8 a=IsR9KNEvvJ06XdSQ7ToA:9 a=ZtUXQEiBMy4-3XEV:21 a=B2KM1_YW6TuXhoBB:21 a=QEXdDO2ut3YA:10 a=_1Fc4GS_WCkA:10 a=rIdUGI8dGKtoV6O39c8A:9 a=ONNS8QRKHyMA:10 a=kfsPDhpdfU4a7g6d8KSe:22 a=diwpeB1DDhFXqWA7J4Up:22 a=KxyM1Xthmv57RbWRIpnN:22 a=fjrkRJ71zQ2jzMzczd-K:22 X-AUTH: skimble@:2500 In-Reply-To: <86eft2s3c0.fsf@zoho.com> (Emanuel Berg's message of "Thu, 27 Jul 2017 10:15:27 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 212.159.14.20 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:113891 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Emanuel Berg 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 =E2=80=98:case-fixed=E2=80=99 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 - =2D-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 =2D-8<---------------cut here---------------end--------------->8--- And this is my main block of code which uses abbrev_defs - =2D-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.ht= ml =2D-8<---------------cut here---------------end--------------->8--- So how do I 'turn on' case-fixed please? Would it be something like - =2D-8<---------------cut here---------------start------------->8--- (setq abbrev-mode case-fixed t) =2D-8<---------------cut here---------------end--------------->8--- Thanks Sharon. =2D-=20 A taste of linux =3D http://www.sharons.org.uk TGmeds =3D http://www.tgmeds.org.uk DrugFacts =3D https://www.drugfacts.org.uk=20=20 Debian 9.0, fluxbox 1.3.5-2, emacs 25.1.1, org-mode 9.0.9 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAll5uw0ACgkQNoGAGQr4 g1s9FQ/+MO9Yxi8l+8Du4b5QdZylAtuVWp6Mz+4ePcjZYoJTzXSoC2EbtfrnO0gZ xxXvC45xhHiBaNFAkvhOypvVoXhkhCiiFnyWkQzVQq6Jff9o1UEbMHQgUyyCRz4n JyhZoc+uhvE3pA5cVfUBL3qrQHUxuokz2PHHVhs8qpCBzQW4YcSyku2uvTHbYhuc Lq8y0V+8NYEVwYcaScUArDggB0+lURTYdsQVz9Y644t2SU2ESjJNlMR0aV9l668W hAsmudvdUUhm129eY0Y5EglBPr+hlJUr7i3i+1hDNVkHovs9Gdzk8wyewRWg615n Y9VfDABDqFxK1cx2vJaGRSzHgyN1drVSr5pFbR/hRe67kYDVQLcdhg1RtM0xQp1S dHkO2KMnB1ChamWY2Vuk1TgF+DP92yu7qSvpfzavAe0Hr5oL9NVKf2lYzjHhbQOA TxYi9CasZDKij6iSIcNdpBMRYG2bNVIgPXsOLm3oPvBBrVWBIM4KObmqC3KRXybB yvullrbHDdx6XefvwysnTlxY2+v0QWkP7MJTjjiFgajMVLSXSiHuvIzDQkRRcI+I PxLt+42m8HaIpzjlF8CagxXLTYqoMhpHJEpOtDrKPI5DOJp2YojL7BuhVc9EDxnm 4H44UC2eiOpEKgW+Tsx4ezI6tHMnhCdZHeTULh8zhCqFqCg6kXE= =mFUX -----END PGP SIGNATURE----- --=-=-=--