all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* capitalised in 'abbrev_defs'?
@ 2017-07-27  7:37 Sharon Kimble
  2017-07-27  8:15 ` Emanuel Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Sharon Kimble @ 2017-07-27  7:37 UTC (permalink / raw)
  To: help-emacs

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


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? I've googled but haven't found any solution to the problem.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: capitalised in 'abbrev_defs'?
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Emanuel Berg @ 2017-07-27  8:15 UTC (permalink / raw)
  To: help-gnu-emacs

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.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: capitalised in 'abbrev_defs'?
  2017-07-27  8:15 ` Emanuel Berg
@ 2017-07-27 10:06   ` Sharon Kimble
  2017-07-27 12:43     ` Kaushal Modi
  2017-07-27 15:10     ` Emanuel Berg
  0 siblings, 2 replies; 5+ messages in thread
From: Sharon Kimble @ 2017-07-27 10:06 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: capitalised in 'abbrev_defs'?
  2017-07-27 10:06   ` Sharon Kimble
@ 2017-07-27 12:43     ` Kaushal Modi
  2017-07-27 15:10     ` Emanuel Berg
  1 sibling, 0 replies; 5+ messages in thread
From: Kaushal Modi @ 2017-07-27 12:43 UTC (permalink / raw)
  To: Sharon Kimble, help-gnu-emacs

On Thu, Jul 27, 2017, 6:07 AM Sharon Kimble <boudiccas@skimble.plus.com>
wrote:

> Emanuel Berg <moasen@zoho.com> writes:
>
>     (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.")
>

You can customize this to only the major modes where you want abbrev-mode
to be enabled. These values are specific to my use case.

>
heavily influenced by kaushalmodi
>

Thanks for the attribute. I wasn't expecting any so I was surprised :)

(setq save-abbrevs 'silently)
>

This is repeating (based on the snippet you pasted above).

(setq-default abbrev-mode t)
>

This would enable abbrev-mode globally. So the per-major-mode abbrev-mode
enabling above would be redundant. Also I wouldn't enable any minor mode by
just setting the mode variable. The canonical way would be to use
(global-FOO-mode 1) or (global-FOO-mode) if global-FOO-mode is defined.

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

Above will not work.

I haven't yet tried but check out the solution someone posted here:
https://stackoverflow.com/a/15315076/1219634

> --

Kaushal Modi


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: capitalised in 'abbrev_defs'?
  2017-07-27 10:06   ` Sharon Kimble
  2017-07-27 12:43     ` Kaushal Modi
@ 2017-07-27 15:10     ` Emanuel Berg
  1 sibling, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2017-07-27 15:10 UTC (permalink / raw)
  To: help-gnu-emacs

Sharon Kimble wrote:

> So how do I 'turn on' case-fixed please?
> Would it be something like -
>
> (setq abbrev-mode case-fixed t)

I would do it on a per-abbrev basis, but it
seems it can be done globally or for each
abbrev tables with the code that is in the URL
Kaushal Modi posted.

Note that this might break expected behavior
from your other abbrevs depending on how you
are used to use them. But it is not like it is
dangerous to try or anything.

Keep it up :)

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-27 15:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-07-27 12:43     ` Kaushal Modi
2017-07-27 15:10     ` Emanuel Berg

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.