unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Custom option to turn Flyspell mode on in prog modes
@ 2013-12-09  0:25 Matthias Meulien
  2013-12-09 13:28 ` Rüdiger Sonderfeld
  0 siblings, 1 reply; 10+ messages in thread
From: Matthias Meulien @ 2013-12-09  0:25 UTC (permalink / raw)
  To: emacs-devel

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

The attached patch allows users to enable spell checking in prog 
modes by customization means. Thanks to `flyspell-prog-mode', the 
spell checking is done in comments and strings only.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Custom-option-to-turn-Flyspell-mode-on-in-prog-modes.patch --]
[-- Type: text/x-diff, Size: 1670 bytes --]

From 0898bacd9012a0d01da417b3f491f008d4bdefe8 Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Mon, 9 Dec 2013 01:20:11 +0100
Subject: [PATCH] Custom option to turn Flyspell mode on in prog modes

---
 lisp/progmodes/prog-mode.el | 6 ++++++
 lisp/textmodes/flyspell.el  | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index b3ed328..92820dc 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -35,6 +35,12 @@
   "Generic programming mode, from which others derive."
   :group 'languages)
 
+(defcustom prog-mode-hook nil
+  "Normal hook run when entering Text mode and many related modes."
+  :type 'hook
+  :options '(turn-on-flyspell-prog)
+  :group 'prog-mode)
+
 (defvar prog-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map [?\C-\M-q] 'prog-indent-sexp)
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 81f17c8..0ce0a90 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -519,11 +519,17 @@ in your init file.
   (flyspell-mode 1))
 
 ;;;###autoload
+(defun turn-on-flyspell-prog ()
+  "Unconditionally turn on Flyspell mode for comments and strings."
+  (flyspell-prog-mode))
+
+;;;###autoload
 (defun turn-off-flyspell ()
   "Unconditionally turn off Flyspell mode."
   (flyspell-mode -1))
 
 (custom-add-option 'text-mode-hook 'turn-on-flyspell)
+(custom-add-option 'prog-mode-hook 'turn-on-flyspell-prog)
 
 ;;*---------------------------------------------------------------------*/
 ;;*    flyspell-buffers ...                                             */
-- 
1.8.5.1


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
Matthias

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

* Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
  2013-12-09  0:25 [PATCH] Custom option to turn Flyspell mode on in prog modes Matthias Meulien
@ 2013-12-09 13:28 ` Rüdiger Sonderfeld
  2013-12-11 23:17   ` Matthias Meulien
  2014-08-14 20:21   ` Mode line strings for sub- and super- minor modes are counterintuitive Matthias Meulien
  0 siblings, 2 replies; 10+ messages in thread
From: Rüdiger Sonderfeld @ 2013-12-09 13:28 UTC (permalink / raw)
  To: emacs-devel; +Cc: Matthias Meulien

On Monday 09 December 2013 01:25:08 Matthias Meulien wrote:
> The attached patch allows users to enable spell checking in prog
> modes by customization means. Thanks to `flyspell-prog-mode', the
> spell checking is done in comments and strings only.

Looks good.  But I don't think `turn-on-flyspell-prog' is needed because 
`flyspell-prog-mode' already turns the mode on unconditionally.  (Although 
maybe the latter should be reconsidered.)

Regards,
Rüdiger




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

* Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
  2013-12-09 13:28 ` Rüdiger Sonderfeld
@ 2013-12-11 23:17   ` Matthias Meulien
  2014-01-07 19:23     ` Glenn Morris
  2014-08-08 13:59     ` Rüdiger Sonderfeld
  2014-08-14 20:21   ` Mode line strings for sub- and super- minor modes are counterintuitive Matthias Meulien
  1 sibling, 2 replies; 10+ messages in thread
From: Matthias Meulien @ 2013-12-11 23:17 UTC (permalink / raw)
  To: Rüdiger Sonderfeld; +Cc: emacs-devel

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

Rüdiger Sonderfeld <ruediger@c-plusplus.de> writes:

> Looks good.  But I don't think `turn-on-flyspell-prog' is needed 
> because  `flyspell-prog-mode' already turns the mode on 
> unconditionally.  (Although  maybe the latter should be 
> reconsidered.) 

You are right. The following works well.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-progmodes-prog-mode.el-Add-custom-options-to-mo.patch --]
[-- Type: text/x-diff, Size: 911 bytes --]

From 29893db295fa1d01f9eec0f3f029b33d9a523a49 Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Thu, 12 Dec 2013 00:09:16 +0100
Subject: [PATCH] lisp/progmodes/prog-mode.el: Add custom options to mode hook

---
 lisp/progmodes/prog-mode.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index b3ed328..f325a67 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -35,6 +35,12 @@
   "Generic programming mode, from which others derive."
   :group 'languages)
 
+(defcustom prog-mode-hook nil
+  "Normal hook run when entering Text mode and many related modes."
+  :type 'hook
+  :options '(flyspell-prog-mode abbrev-mode flymake-mode linum-mode)
+  :group 'prog-mode)
+
 (defvar prog-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map [?\C-\M-q] 'prog-indent-sexp)
-- 
1.8.5.1


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
Matthias

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

* Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
  2013-12-11 23:17   ` Matthias Meulien
@ 2014-01-07 19:23     ` Glenn Morris
  2014-01-07 19:30       ` Glenn Morris
  2014-08-08 13:59     ` Rüdiger Sonderfeld
  1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2014-01-07 19:23 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: Rüdiger Sonderfeld, emacs-devel


Thanks; filed as http://debbugs.gnu.org/16394 so it does get lost.



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

* Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
  2014-01-07 19:23     ` Glenn Morris
@ 2014-01-07 19:30       ` Glenn Morris
  0 siblings, 0 replies; 10+ messages in thread
From: Glenn Morris @ 2014-01-07 19:30 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: Rüdiger Sonderfeld, emacs-devel

Glenn Morris wrote:

> Thanks; filed as http://debbugs.gnu.org/16394 so it does get lost.

Whoops: s/does get/does not get/



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

* Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
  2013-12-11 23:17   ` Matthias Meulien
  2014-01-07 19:23     ` Glenn Morris
@ 2014-08-08 13:59     ` Rüdiger Sonderfeld
  2014-08-08 23:45       ` Juri Linkov
  1 sibling, 1 reply; 10+ messages in thread
From: Rüdiger Sonderfeld @ 2014-08-08 13:59 UTC (permalink / raw)
  To: emacs-devel; +Cc: Matthias Meulien

On Thursday 12 December 2013 00:17:25 Matthias Meulien wrote:
> Rüdiger Sonderfeld <ruediger@c-plusplus.de> writes:
> > Looks good.  But I don't think `turn-on-flyspell-prog' is needed
> > because  `flyspell-prog-mode' already turns the mode on
> > unconditionally.  (Although  maybe the latter should be
> > reconsidered.)
> 
> You are right. The following works well.

Sorry for the long delay.  I have applied the patch (r117667) and also added 
`prettify-symbols-mode' to the list.

Regards,
Rüdiger




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

* Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
  2014-08-08 13:59     ` Rüdiger Sonderfeld
@ 2014-08-08 23:45       ` Juri Linkov
  2014-08-14 12:46         ` Sebastien Vauban
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2014-08-08 23:45 UTC (permalink / raw)
  To: Rüdiger Sonderfeld; +Cc: Matthias Meulien, emacs-devel

>> > Looks good.  But I don't think `turn-on-flyspell-prog' is needed
>> > because  `flyspell-prog-mode' already turns the mode on
>> > unconditionally.  (Although  maybe the latter should be
>> > reconsidered.)
>>
>> You are right. The following works well.
>
> Sorry for the long delay.  I have applied the patch (r117667) and also added
> `prettify-symbols-mode' to the list.

BTW, could someone suggest how to turn Flyspell mode only on typing
new text, but not on moving point over the existing text?  Would it be
good to have a new custom option as well?  I've tried such ugly hacks,
but they don't work well:

  ;; Flyspell only on typing, not on moving point
  (add-hook 'flyspell-mode-hook
            (lambda ()
              (remove-hook 'post-command-hook (function flyspell-post-command-hook) t)
              (add-hook 'after-change-functions
                        (lambda (start stop len)
                          (flyspell-post-command-hook)) t t)))

  ;; Alternative solution for Flyspell only on typing, not on moving point
  (add-hook 'flyspell-mode-hook
            (lambda ()
              (advice-add 'flyspell-check-pre-word-p :override (lambda () nil))
              ;; After evaluating the next, flyspell doesn't check the last word
              ;; in `auto-fill-mode' when typing SPC moves to the next line,
              ;; because the order of calls in `internal_self_insert' is:
              ;; 1. insert_and_inherit ();
              ;; 2. Frun_hook_with_args (Qafter_change_functions);
              ;; 3. auto_fill_result = call0 (BVAR (current_buffer, auto_fill_function));
              ;; 4. Frun_hooks (1, &Qpost_self_insert_hook);
              (advice-add 'flyspell-check-word-p     :override (lambda () nil))))



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

* Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
  2014-08-08 23:45       ` Juri Linkov
@ 2014-08-14 12:46         ` Sebastien Vauban
  0 siblings, 0 replies; 10+ messages in thread
From: Sebastien Vauban @ 2014-08-14 12:46 UTC (permalink / raw)
  To: emacs-devel-mXXj517/zsQ

Juri Linkov wrote:
>>> > Looks good.  But I don't think `turn-on-flyspell-prog' is needed
>>> > because  `flyspell-prog-mode' already turns the mode on
>>> > unconditionally.  (Although  maybe the latter should be
>>> > reconsidered.)
>>>
>>> You are right. The following works well.
>>
>> Sorry for the long delay.  I have applied the patch (r117667) and also added
>> `prettify-symbols-mode' to the list.
>
> BTW, could someone suggest how to turn Flyspell mode only on typing
> new text, but not on moving point over the existing text?  Would it be
> good to have a new custom option as well?  I've tried such ugly hacks,
> but they don't work well:
>
>   ;; Flyspell only on typing, not on moving point
>   (add-hook 'flyspell-mode-hook
>             (lambda ()
>               (remove-hook 'post-command-hook (function flyspell-post-command-hook) t)
>               (add-hook 'after-change-functions
>                         (lambda (start stop len)
>                           (flyspell-post-command-hook)) t t)))
>
>   ;; Alternative solution for Flyspell only on typing, not on moving point
>   (add-hook 'flyspell-mode-hook
>             (lambda ()
>               (advice-add 'flyspell-check-pre-word-p :override (lambda () nil))
>               ;; After evaluating the next, flyspell doesn't check the last word
>               ;; in `auto-fill-mode' when typing SPC moves to the next line,
>               ;; because the order of calls in `internal_self_insert' is:
>               ;; 1. insert_and_inherit ();
>               ;; 2. Frun_hook_with_args (Qafter_change_functions);
>               ;; 3. auto_fill_result = call0 (BVAR (current_buffer, auto_fill_function));
>               ;; 4. Frun_hooks (1, &Qpost_self_insert_hook);
>               (advice-add 'flyspell-check-word-p     :override (lambda () nil))))

Why don't they work well?

Note that an approach that seduced me was to only check the buffer once
it gets modified.

--8<---------------cut here---------------start------------->8---
  (add-hook 'first-change-hook
             #'(lambda ()
                 (when (and (memq major-mode my-flyspell-major-mode-list)
                            (not flyspell-mode))
                   (my-turn-on-flyspell-french))))
--8<---------------cut here---------------end--------------->8---

However, I have dropped that because it had problems as well -- though,
I don't remember which ones exactly (done during Org mode exports or
so?).

Best regards,
  Seb

-- 
Sebastien Vauban




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

* Mode line strings for sub- and super- minor modes are counterintuitive
  2013-12-09 13:28 ` Rüdiger Sonderfeld
  2013-12-11 23:17   ` Matthias Meulien
@ 2014-08-14 20:21   ` Matthias Meulien
  2014-08-15  5:45     ` Bozhidar Batsov
  1 sibling, 1 reply; 10+ messages in thread
From: Matthias Meulien @ 2014-08-14 20:21 UTC (permalink / raw)
  To: emacs-devel

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

When subword (resp. superword) minor mode is enabled, a comma 
(resp. a superscript two) is displayed in the mode line. I found 
those two characters difficult to see and meaning less.

I understand that there's not much space in the mode line but 
other minor modes are much verbose (eg. MML, Abbrev, Fill, Narrow, 
Outl, etc). Why subword and superword modes have this special 
treatment?

I suggest to use Subw and Supw for the user to have a chance to 
link the mode line string to the full minor mode.


[-- Attachment #2: Change mode line string for subword-mode and superword-mode --]
[-- Type: text/x-diff, Size: 1056 bytes --]

From 9697e30918fa3cc0a4c741ee8f1774f3e67ab173 Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Thu, 14 Aug 2014 22:11:51 +0200
Subject: [PATCH] Change mode line string for subword-mode and superword-mode

---
 lisp/progmodes/subword.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el
index a8455c5..9b65cda 100644
--- a/lisp/progmodes/subword.el
+++ b/lisp/progmodes/subword.el
@@ -116,7 +116,7 @@ This mode changes the definition of a word so that word commands
 treat nomenclature boundaries as word bounaries.
 
 \\{subword-mode-map}"
-    :lighter " ,"
+    :lighter " Subw"
     (when subword-mode (superword-mode -1))
     (subword-setup-buffer))
 
@@ -279,7 +279,7 @@ as parts of words: e.g., in `superword-mode',
 \"this_is_a_symbol\" counts as one word.
 
 \\{superword-mode-map}"
-    :lighter " ²"
+    :lighter " Supw"
     (when superword-mode (subword-mode -1))
     (subword-setup-buffer))
 
-- 
2.0.4


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]


– 
Matthias

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

* Re: Mode line strings for sub- and super- minor modes are counterintuitive
  2014-08-14 20:21   ` Mode line strings for sub- and super- minor modes are counterintuitive Matthias Meulien
@ 2014-08-15  5:45     ` Bozhidar Batsov
  0 siblings, 0 replies; 10+ messages in thread
From: Bozhidar Batsov @ 2014-08-15  5:45 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: emacs-devel

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

I totally agree - such lighters are quite confusing. I think the practice of using punctuation characters only for minor-mode lighters should be discouraged.
— 
Cheers,
Bozhidar

On August 14, 2014 at 23:21:51, Matthias Meulien (orontee@gmail.com) wrote:

When subword (resp. superword) minor mode is enabled, a comma  
(resp. a superscript two) is displayed in the mode line. I found  
those two characters difficult to see and meaning less.  

I understand that there's not much space in the mode line but  
other minor modes are much verbose (eg. MML, Abbrev, Fill, Narrow,  
Outl, etc). Why subword and superword modes have this special  
treatment?  

I suggest to use Subw and Supw for the user to have a chance to  
link the mode line string to the full minor mode.  


–  
Matthias  

[-- Attachment #2: Type: text/html, Size: 1575 bytes --]

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

end of thread, other threads:[~2014-08-15  5:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-09  0:25 [PATCH] Custom option to turn Flyspell mode on in prog modes Matthias Meulien
2013-12-09 13:28 ` Rüdiger Sonderfeld
2013-12-11 23:17   ` Matthias Meulien
2014-01-07 19:23     ` Glenn Morris
2014-01-07 19:30       ` Glenn Morris
2014-08-08 13:59     ` Rüdiger Sonderfeld
2014-08-08 23:45       ` Juri Linkov
2014-08-14 12:46         ` Sebastien Vauban
2014-08-14 20:21   ` Mode line strings for sub- and super- minor modes are counterintuitive Matthias Meulien
2014-08-15  5:45     ` Bozhidar Batsov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).