* Some further problems with enriched mode.
@ 2004-09-23 1:18 Luc Teirlinck
2004-09-23 15:47 ` Kevin Rodgers
2004-09-23 16:44 ` Richard Stallman
0 siblings, 2 replies; 6+ messages in thread
From: Luc Teirlinck @ 2004-09-23 1:18 UTC (permalink / raw
When foo-mode is a minor mode, I would normally expect that running
(foo-mode) twice in succession would be a no-op. With `enriched-mode'
this is not the case. Enabling and immediately disabling Enriched
mode will leave hard newlines enabled, even if they were previously
disabled. It will also result in `default-text-properties' being made
buffer local, even if it was not before (it is not buffer local by
default). The following patch would make enabling and disabling
Enriched mode a no-op.
I can install if desired.
===File ~/enriched.el-diff==================================
*** enriched.el 14 Sep 2004 17:10:54 -0500 1.5
--- enriched.el 22 Sep 2004 19:04:51 -0500
***************
*** 154,159 ****
--- 154,165 ----
The value is a list of \(VAR VALUE VAR VALUE...).")
(make-variable-buffer-local 'enriched-old-bindings)
+ ;; The next variable is buffer local if and only if Enriched mode is
+ ;; enabled. The buffer local value records whether
+ ;; `default-text-properties' should remain buffer local when disabling
+ ;; Enriched mode. For technical reasons, the default value should be t.
+ (defvar enriched-default-text-properties-local-flag t)
+
;; Technical internal variable. Bound to t if `enriched-mode' is
;; being rerun by a major mode to allow it to restore buffer-local
;; variables and to correctly update `enriched-old-bindings'.
***************
*** 169,175 ****
"Minor mode for editing text/enriched files.
These are files with embedded formatting information in the MIME standard
text/enriched format.
! Turning the mode on runs `enriched-mode-hook'.
More information about Enriched mode is available in the file
etc/enriched.doc in the Emacs distribution directory.
--- 175,181 ----
"Minor mode for editing text/enriched files.
These are files with embedded formatting information in the MIME standard
text/enriched format.
! Turning the mode on or off runs `enriched-mode-hook'.
More information about Enriched mode is available in the file
etc/enriched.doc in the Emacs distribution directory.
***************
*** 183,189 ****
(setq buffer-file-format (delq 'text/enriched buffer-file-format))
;; restore old variable values
(while enriched-old-bindings
! (set (pop enriched-old-bindings) (pop enriched-old-bindings))))
((and (memq 'text/enriched buffer-file-format)
(not enriched-rerun-flag))
--- 189,199 ----
(setq buffer-file-format (delq 'text/enriched buffer-file-format))
;; restore old variable values
(while enriched-old-bindings
! (set (pop enriched-old-bindings) (pop enriched-old-bindings)))
! (unless enriched-default-text-properties-local-flag
! (kill-local-variable 'default-text-properties))
! (kill-local-variable 'enriched-default-text-properties-local-flag)
! (unless use-hard-newlines (use-hard-newlines 0)))
((and (memq 'text/enriched buffer-file-format)
(not enriched-rerun-flag))
***************
*** 196,202 ****
;; These will be restored if we exit Enriched mode.
(setq enriched-old-bindings
(list 'buffer-display-table buffer-display-table
! 'default-text-properties default-text-properties))
(make-local-variable 'default-text-properties)
(setq buffer-display-table enriched-display-table)
(use-hard-newlines 1 (if enriched-rerun-flag 'never nil))
--- 206,216 ----
;; These will be restored if we exit Enriched mode.
(setq enriched-old-bindings
(list 'buffer-display-table buffer-display-table
! 'default-text-properties default-text-properties
! 'use-hard-newlines use-hard-newlines))
! (make-local-variable 'enriched-default-text-properties-local-flag)
! (setq enriched-default-text-properties-local-flag
! (local-variable-p 'default-text-properties))
(make-local-variable 'default-text-properties)
(setq buffer-display-table enriched-display-table)
(use-hard-newlines 1 (if enriched-rerun-flag 'never nil))
============================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Some further problems with enriched mode.
2004-09-23 1:18 Some further problems with enriched mode Luc Teirlinck
@ 2004-09-23 15:47 ` Kevin Rodgers
2004-09-23 15:59 ` Luc Teirlinck
2004-09-23 16:44 ` Richard Stallman
1 sibling, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2004-09-23 15:47 UTC (permalink / raw
Luc Teirlinck wrote:
> ***************
> *** 169,175 ****
> "Minor mode for editing text/enriched files.
> These are files with embedded formatting information in the MIME standard
> text/enriched format.
> ! Turning the mode on runs `enriched-mode-hook'.
>
> More information about Enriched mode is available in the file
> etc/enriched.doc in the Emacs distribution directory.
> --- 175,181 ----
> "Minor mode for editing text/enriched files.
> These are files with embedded formatting information in the MIME standard
> text/enriched format.
> ! Turning the mode on or off runs `enriched-mode-hook'.
^^^^^^
I know enriched-mode isn't normal, but that doesn't seem right.
> More information about Enriched mode is available in the file
> etc/enriched.doc in the Emacs distribution directory.
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Some further problems with enriched mode.
2004-09-23 15:47 ` Kevin Rodgers
@ 2004-09-23 15:59 ` Luc Teirlinck
2004-09-23 16:44 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Luc Teirlinck @ 2004-09-23 15:59 UTC (permalink / raw
Cc: emacs-devel
Kevin Rodgers wrote:
> ! Turning the mode on or off runs `enriched-mode-hook'.
^^^^^^
I know enriched-mode isn't normal, but that doesn't seem right.
Minor mode hooks are run when turning the mode on _or_ off.
Do `emacs -q', `M-x ielm' and:
ELISP> (add-hook 'enriched-mode-hook (lambda () (defvar myflag 5)))
((lambda nil
(defvar myflag 5)))
ELISP> (enriched-mode 0)
nil
ELISP> myflag
5
ELISP>
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Some further problems with enriched mode.
2004-09-23 15:59 ` Luc Teirlinck
@ 2004-09-23 16:44 ` Stefan Monnier
2004-09-23 17:24 ` Luc Teirlinck
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2004-09-23 16:44 UTC (permalink / raw
Cc: ihs_4664, emacs-devel
> Minor mode hooks are run when turning the mode on _or_ off.
Indeed.
Some minor modes only run their run when turned ON, but I think it's a bug,
because in many cases it can be useful/important to run something when the
mode is turned OFF.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Some further problems with enriched mode.
2004-09-23 1:18 Some further problems with enriched mode Luc Teirlinck
2004-09-23 15:47 ` Kevin Rodgers
@ 2004-09-23 16:44 ` Richard Stallman
1 sibling, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2004-09-23 16:44 UTC (permalink / raw
Cc: emacs-devel
Please install your changes, and thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Some further problems with enriched mode.
2004-09-23 16:44 ` Stefan Monnier
@ 2004-09-23 17:24 ` Luc Teirlinck
0 siblings, 0 replies; 6+ messages in thread
From: Luc Teirlinck @ 2004-09-23 17:24 UTC (permalink / raw
Cc: ihs_4664, emacs-devel
Stefan Monnier wrote:
> Minor mode hooks are run when turning the mode on _or_ off.
Indeed.
Some minor modes only run their run when turned ON, but I think it's a bug,
because in many cases it can be useful/important to run something when the
mode is turned OFF.
In particular, when turning the mode off, the user needs to be able to
undo changes he made (using the hook) while turning the mode on.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-09-23 17:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-23 1:18 Some further problems with enriched mode Luc Teirlinck
2004-09-23 15:47 ` Kevin Rodgers
2004-09-23 15:59 ` Luc Teirlinck
2004-09-23 16:44 ` Stefan Monnier
2004-09-23 17:24 ` Luc Teirlinck
2004-09-23 16:44 ` Richard Stallman
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.