abbrev_defs & capitalised words

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

abbrev_defs & capitalised words

Sharon Kimble-2

I'm having a big problem with new words that are added to abbrev_defs if the word I want it to be is capitalised. How can I get emacs to save it capitalised please, as its only doing it in lower-case.

Example - Sunday shows in abbrev_defs as, (or would if it was actually saved, which it isn't!)

--8<---------------cut here---------------start------------->8---
"sunday"    0     "sunday"
--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.9, fluxbox 1.3.7, emacs 26.2, org 9.2.3

signature.asc (847 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: abbrev_defs & capitalised words

Eli Zaretskii
> From: Sharon Kimble <[hidden email]>
> Date: Fri, 24 May 2019 08:41:32 +0100
>
> I'm having a big problem with new words that are added to abbrev_defs if the word I want it to be is capitalised. How can I get emacs to save it capitalised please, as its only doing it in lower-case.

Did you read the doc string of 'define-abbrev'?

Reply | Threaded
Open this post in threaded view
|

Re: abbrev_defs & capitalised words

Sharon Kimble-2
Eli Zaretskii <[hidden email]> writes:

>> From: Sharon Kimble <[hidden email]>
>> Date: Fri, 24 May 2019 08:41:32 +0100
>>
>> I'm having a big problem with new words that are added to abbrev_defs if the word I want it to be is capitalised. How can I get emacs to save it capitalised please, as its only doing it in lower-case.
>
> Did you read the doc string of 'define-abbrev'?

I'm not sure what you mean, so I googled it, which led to [1], [2], and finally [3]. And I'm still not sure what you mean! But this might be what you mean, from my abbrev_defs  -

--8<---------------cut here---------------start------------->8---
define-abbrev-table 'global-abbrev-table
--8<---------------cut here---------------end--------------->8---

What I'm hoping for is something that I can put in my config which will save capitalised entries into my abbrev_defs.

Thanks
Sharon.

[:1] http://www.jedsoft.org/jed/doc/jedfuns-5.html
[:2] https://stackoverflow.com/questions/19032166/how-to-abbreviate-path-in-emacs
[:3] The emacs manual (Seventeenth Edition, Updated for Emacs Version 27.0.50.) and Section 26 - Abbrevs
--
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 9.9, fluxbox 1.3.7, emacs 26.2, org 9.2.3

signature.asc (847 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: abbrev_defs & capitalised words

Tomas Zerolo
On Fri, May 24, 2019 at 12:56:02PM +0100, Sharon Kimble wrote:

> Eli Zaretskii <[hidden email]> writes:
>
> >> From: Sharon Kimble <[hidden email]>
> >> Date: Fri, 24 May 2019 08:41:32 +0100
> >>
> >> I'm having a big problem with new words that are added to abbrev_defs if the word I want it to be is capitalised. How can I get emacs to save it capitalised please, as its only doing it in lower-case.
> >
> > Did you read the doc string of 'define-abbrev'?
>
> I'm not sure what you mean, so I googled it, which led to [1], [2], and finally [3]. And I'm still not sure what you mean! But this might be what you mean, from my abbrev_defs  -
Just start an Emacs and type C-h f (that is "describe function"). The
minubuffer asks you for a function name, you type in 'define-abbrev'
(without the quotes), then ENTER.

Alternatively, via the menu: Help -> Describe... -> Describe Function...

This will lead you to the function's documentation string.

Cheers
-- t

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: abbrev_defs & capitalised words

Eli Zaretskii
In reply to this post by Sharon Kimble-2
> From: Sharon Kimble <[hidden email]>
> Cc: [hidden email]
> Date: Fri, 24 May 2019 12:56:02 +0100
>
> > Did you read the doc string of 'define-abbrev'?
>
> I'm not sure what you mean, so I googled it, which led to [1], [2], and finally [3]. And I'm still not sure what you mean!


I meant what Emacs shows when you type "C-h f define-abbrev RET".  It
says this:

  (define-abbrev TABLE NAME EXPANSION &optional HOOK &rest PROPS)

  Define an abbrev in TABLE named NAME, to expand to EXPANSION and call HOOK.
  NAME must be a string, and should be lower-case.
  EXPANSION should usually be a string.

  [...]

  PROPS is a property list.  The following properties are special:
  - ‘:count’: the value for the abbrev’s usage-count, which is incremented each
    time the abbrev is used (the default is zero).
  - ‘:system’: if non-nil, says that this is a "system" abbreviation
    which should not be saved in the user’s abbreviation file.
    Unless ‘:system’ is ‘force’, a system abbreviation will not
    overwrite a non-system abbreviation of the same name.
  - ‘:case-fixed’: non-nil means that abbreviations are looked up without
    case-folding, and the expansion is not capitalized/upcased.
  - ‘:enable-function’: a function of no argument which returns non-nil if the
    abbrev should be used for a particular call of ‘expand-abbrev’.

Note the ‘:case-fixed’ part: isn't that what you want?  If so, you
could modify your abbrev_defs file to make select abbrevs have fixed
letter-case.

Reply | Threaded
Open this post in threaded view
|

Re: abbrev_defs & capitalised words

Sharon Kimble-2
In reply to this post by Tomas Zerolo
<[hidden email]> writes:

> On Fri, May 24, 2019 at 12:56:02PM +0100, Sharon Kimble wrote:
>> Eli Zaretskii <[hidden email]> writes:
>>
>> >> From: Sharon Kimble <[hidden email]>
>> >> Date: Fri, 24 May 2019 08:41:32 +0100
>> >>
>> >> I'm having a big problem with new words that are added to abbrev_defs if the word I want it to be is capitalised. How can I get emacs to save it capitalised please, as its only doing it in lower-case.
>> >
>> > Did you read the doc string of 'define-abbrev'?
>>
>> I'm not sure what you mean, so I googled it, which led to [1], [2], and finally [3]. And I'm still not sure what you mean! But this might be what you mean, from my abbrev_defs  -
>
> Just start an Emacs and type C-h f (that is "describe function"). The
> minubuffer asks you for a function name, you type in 'define-abbrev'
> (without the quotes), then ENTER.
>
> Alternatively, via the menu: Help -> Describe... -> Describe Function...
>
> This will lead you to the function's documentation string.
>
> Cheers
> -- t
Thanks Eli and Tomas.

I've looked at the *Help* for define-abbrevs, but not being a programmer I don't really understand it. So here is my complete spell-checking from my config, if anyone can help me tweak it to allow capitalisation to take place?

--8<---------------cut here---------------start------------->8---
** Spell-check

#+BEGIN_SRC emacs-lisp
(setq ispell-personal-dictionary "~/.emacs.d/ac-dict/my-ispell-dict")
#+END_SRC
[2019-04-18 Thu 13:15]

#+BEGIN_SRC emacs-lisp
(dolist (hook '(text-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))
#+END_SRC
[2019-04-18 Thu 06:09]
https://joelkuiper.eu/spellcheck_emacs

#+BEGIN_SRC emacs-lisp
(defun ispell-word-then-abbrev (p)
  "Call `ispell-word'. Then create an abbrev for the correction made.
With prefix P, create local abbrev. Otherwise it will be global."
  (interactive "P")
  (let ((before (downcase (or (thing-at-point 'word) "")))
        after)
    (call-interactively 'ispell-word)
    (setq after (downcase (or (thing-at-point 'word) "")))
    (unless (string= after before)
      (define-abbrev
        (if p local-abbrev-table global-abbrev-table) before after))
      (message "\"%s\" now expands to \"%s\" %sally."
               before after (if p "loc" "glob"))))

(define-key ctl-x-map (kbd "C-i") 'ispell-word-then-abbrev)
(setq save-abbrevs t)
(setq-default abbrev-mode t)
#+END_SRC
[2019-04-18 Thu 06:10]
https://emacs.stackexchange.com/questions/2167/what-options-are-there-for-doing-spell-checking-in-emacs?rq=1

#+BEGIN_SRC emacs-lisp
(defun flyspell-buffer-after-pdict-save (&rest _)
  (flyspell-buffer))

(advice-add 'ispell-pdict-save :after #'flyspell-buffer-after-pdict-save)
#+END_SRC
[2019-04-18 Thu 06:13]
https://www.emacswiki.org/emacs/FlySpell#toc6

#+BEGIN_SRC emacs-lisp
    (defun flyspell-emacs-popup-textual (event poss word)
      "A textual flyspell popup menu."
      (require 'popup)
      (let* ((corrects (if flyspell-sort-corrections
                           (sort (car (cdr (cdr poss))) 'string<)
                         (car (cdr (cdr poss)))))
             (cor-menu (if (consp corrects)
                           (mapcar (lambda (correct)
                                     (list correct correct))
                                   corrects)
                         '()))
             (affix (car (cdr (cdr (cdr poss)))))
             show-affix-info
             (base-menu  (let ((save (if (and (consp affix) show-affix-info)
                                         (list
                                          (list (concat "Save affix: " (car affix))
                                                'save)
                                          '("Accept (session)" session)
                                          '("Accept (buffer)" buffer))
                                       '(("Save word" save)
                                         ("Accept (session)" session)
                                         ("Accept (buffer)" buffer)))))
                           (if (consp cor-menu)
                               (append cor-menu (cons "" save))
                             save)))
             (menu (mapcar
                    (lambda (arg) (if (consp arg) (car arg) arg))
                    base-menu)))
        (cadr (assoc (popup-menu* menu :scroll-bar t) base-menu))))
#+END_SRC
[2019-04-18 Thu 06:15]
https://www.emacswiki.org/emacs/FlySpell

https://github.com/clemera/flyspell-correct

#+BEGIN_SRC emacs-lisp
(require 'flyspell-correct-popup)
(define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-wrapper)
#+END_SRC
[2019-04-18 Thu 12:46]
--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.9, fluxbox 1.3.7, emacs 26.2, org 9.2.3

signature.asc (847 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: abbrev_defs & capitalised words

Stefan Monnier
>   (add-hook hook (lambda () (flyspell-mode 1))))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AKA                #'flyspell-mode


        Stefan