Re: [Orgmode] Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
Hi Martin, this looks to me like a bug in whitespace.el, why does it override the display table org-mode is using? - Carsten On Dec 2, 2009, at 8:02 PM, Martin Pohlack wrote: Remember to cover the basics, that is, what you expected to happen and what in fact did happen. You don't know how to make a good report? See http://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org-mode mailing list. I observe a strange interaction between whitespace-mode and org-mode if org-ellipsis is set. Whenever I use whitespace-toggle-options for customizing whitespace-mode in a buffer, all org-mode buffers are effected. Probably their display table is overwritten which only has effect if org-ellipsis is set? Steps to reproduce: * Start emacs as follows (no local init file, start attached minimal init file, open two small org-files, also attached): $ emacs -q -l init.test.el test1.org test2.org * Hit F10 in one org-mode buffer once. * Look at other org-mode buffer to see that spaces are visualized via a centered dot. What *is* happening: * Other buffers are effected by a supposedly local action (display table?). What *should* be happening: * No change to other buffers should occur. I'm not entirely convinced that org-mode is to blame here ... Emacs : GNU Emacs 23.1.1 (i686-pc-linux-gnu, GTK+ Version 2.14.7) of 2009-09-17 on monat400 Package: Org-mode version 6.21b Package: Org-mode version 6.32trans Org-settings see attachment. (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(org-ellipsis "…")) (require 'whitespace) (defvar cycle-whitespace-modes-state 0 "whitespace mode states: 0 -> highlighting of stray whitespace, 72 & 80 column lines 1 -> ws highlighting and identification for tabs and spaces (», ·)") (make-variable-buffer-local 'cycle-whitespace-modes-state) (defun my-cycle-whitespace-modes (&optional state) (interactive) (if state (setq cycle-whitespace-modes-state state) (setq cycle-whitespace-modes-state (mod (1+ cycle-whitespace-modes-state) 2))) (case cycle-whitespace-modes-state (0 (whitespace-mode 0) ) (otherwise (whitespace-mode 0) (whitespace-mode 1) (whitespace-toggle-options (list 'tab-mark 'space-mark)) ))) (global-set-key [f10] 'my-cycle-whitespace-modes) abc def abc def ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
Carsten Dominik wrote: > Hi Martin, this looks to me like a bug in whitespace.el, why does it > override the display table org-mode is using? Hmm, my understanding is that each buffer can have its own display table, buffer-display-table. whitespace-mode has to modify this table (or install an own one) if it wants to do buffer-local modifications. So I think it modifies org-mode's table but doesn't override it. My irritation is that by doing so, it does modifies some global state that effects other buffers. A short look into org.el shows that org-display-table is never made buffer local, so this data structure is shared across all org-mode buffers? The following hack seems to solve this problem: --- org.el.bak 2009-12-03 22:31:07.0 +0100 +++ org.el 2009-12-03 22:31:48.0 +0100 @@ -427,9 +427,6 @@ (face :tag "Face" :value org-warning) (string :tag "String" :value "...#"))) -(defvar org-display-table nil - "The display table for org-mode, in case `org-ellipsis' is non-nil.") - (defgroup org-keywords nil "Keywords in Org-mode." :tag "Org Keywords" @@ -4170,8 +4167,7 @@ (when (and org-ellipsis (fboundp 'set-display-table-slot) (boundp 'buffer-display-table) (fboundp 'make-glyph-code)) -(unless org-display-table - (setq org-display-table (make-display-table))) +(setq org-display-table (make-display-table)) (set-display-table-slot org-display-table 4 (vconcat (mapcar Cheers, Martin ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
On Dec 3, 2009, at 10:34 PM, Martin Pohlack wrote: Carsten Dominik wrote: Hi Martin, this looks to me like a bug in whitespace.el, why does it override the display table org-mode is using? Hmm, my understanding is that each buffer can have its own display table, buffer-display-table. whitespace-mode has to modify this table (or install an own one) if it wants to do buffer-local modifications. So I think it modifies org-mode's table but doesn't override it. My irritation is that by doing so, it does modifies some global state that effects other buffers. A short look into org.el shows that org-display-table is never made buffer local, so this data structure is shared across all org-mode buffers? Yes, this is the idea, and it seems only logical to me. So why do you want different settings in different Org buffers for whitespace? So far I am unconvinced that creating a new table in each buffer with the right thing to do. - Carsten The following hack seems to solve this problem: --- org.el.bak 2009-12-03 22:31:07.0 +0100 +++ org.el 2009-12-03 22:31:48.0 +0100 @@ -427,9 +427,6 @@ (face :tag "Face" :value org-warning) (string :tag "String" :value "...#"))) -(defvar org-display-table nil - "The display table for org-mode, in case `org-ellipsis' is non- nil.") - (defgroup org-keywords nil "Keywords in Org-mode." :tag "Org Keywords" @@ -4170,8 +4167,7 @@ (when (and org-ellipsis (fboundp 'set-display-table-slot) (boundp 'buffer-display-table) (fboundp 'make-glyph-code)) -(unless org-display-table - (setq org-display-table (make-display-table))) +(setq org-display-table (make-display-table)) (set-display-table-slot org-display-table 4 (vconcat (mapcar Cheers, Martin - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
Carsten Dominik wrote: > On Dec 3, 2009, at 10:34 PM, Martin Pohlack wrote: > >> Carsten Dominik wrote: >>> Hi Martin, this looks to me like a bug in whitespace.el, why does it >>> override the display table org-mode is using? >> Hmm, my understanding is that each buffer can have its own display >> table, buffer-display-table. whitespace-mode has to modify this table >> (or install an own one) if it wants to do buffer-local modifications. >> So I think it modifies org-mode's table but doesn't override it. >> >> My irritation is that by doing so, it does modifies some global state >> that effects other buffers. >> >> A short look into org.el shows that org-display-table is never made >> buffer local, so this data structure is shared across all org-mode >> buffers? > > Yes, this is the idea, and it seems only logical to me. So why > do you want different settings in different Org buffers for > whitespace? So far I am unconvinced that creating a new > table in each buffer with the right thing to do. Ok, I have three argument to support this. 1. Let me start by describing a helper and how I use it. This is a snippet from my init.el: 8<-->8 ;;; ;;; whitespace stuff ;;; (when (require 'whitespace nil t) (require 'column-marker) (defvar cycle-whitespace-modes-state 0 "whitespace mode states: 0 -> no whitespace stuff, 1 -> highlighting of stray whitespace, 72 & 80 column lines 2 -> ws highlighting and identification for tabs and spaces (», ·)") (make-variable-buffer-local 'cycle-whitespace-modes-state) (defun my-cycle-whitespace-modes (&optional state) (interactive) (if state (setq cycle-whitespace-modes-state state) (setq cycle-whitespace-modes-state (mod (1+ cycle-whitespace-modes-state) 3))) (case cycle-whitespace-modes-state (0 (whitespace-mode 0) (column-marker-1 -2) (column-marker-2 -2) (column-marker-3 -2)) (1 (whitespace-mode 0) (whitespace-mode 1) (column-marker-1 72) (column-marker-2 80)) (otherwise (whitespace-mode 0) (whitespace-mode 1) (whitespace-toggle-options (list 'tab-mark 'space-mark)) (column-marker-1 72) (column-marker-2 80 (global-set-key [f10] 'my-cycle-whitespace-modes) (defun my-whitespace-modes-none () (my-cycle-whitespace-modes 0)) (defun my-whitespace-modes-some () (my-cycle-whitespace-modes 1)) (defun my-whitespace-modes-full () (my-cycle-whitespace-modes 2)) (add-hook 'c-mode-common-hook 'my-whitespace-modes-some) ;… ) 8<-->8 I usually have whitespace mode active in a medium warning level (my-whitespace-modes-some), which show whitespace at end of line etc. Sometimes, I want to see all spaces and tabs in a single buffer explicitly, e.g. for aligning stuff manually or debugging things (my-whitespace-modes-full). At other times, I want to deactivate all whitespace highlighting (my-whitespace-modes-none), e.g., when dealing with long lines or when crafting some ASCII drawings. I make, all of these decision per buffer. 2. Whitespace-mode is usually buffer local. Having it modify other buffers is irritating. If global effects are desired there is the variable whitespace-global-modes 3. (whitespace-toggle-options …) is documented to modify the local buffer only. Org's global display table de-localizes all of whitespace-mode's local functionality. Cheers, Martin ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
Hi Martin, i can follow your arguments and would like to improve this. What I do not understand yet is this: I was under the impression that normally, there is only a single display table in Emacs, and that is the global one and every buffer will use it. So it would seem to me that whitespace-mode would normally *make* a local table in order to put its changes in there. However, that does not seem to be the case here. Can you see why? - Carsten On Dec 4, 2009, at 4:41 PM, Martin Pohlack wrote: Carsten Dominik wrote: On Dec 3, 2009, at 10:34 PM, Martin Pohlack wrote: Carsten Dominik wrote: Hi Martin, this looks to me like a bug in whitespace.el, why does it override the display table org-mode is using? Hmm, my understanding is that each buffer can have its own display table, buffer-display-table. whitespace-mode has to modify this table (or install an own one) if it wants to do buffer-local modifications. So I think it modifies org-mode's table but doesn't override it. My irritation is that by doing so, it does modifies some global state that effects other buffers. A short look into org.el shows that org-display-table is never made buffer local, so this data structure is shared across all org-mode buffers? Yes, this is the idea, and it seems only logical to me. So why do you want different settings in different Org buffers for whitespace? So far I am unconvinced that creating a new table in each buffer with the right thing to do. Ok, I have three argument to support this. 1. Let me start by describing a helper and how I use it. This is a snippet from my init.el: 8<-->8 ;;; ;;; whitespace stuff ;;; (when (require 'whitespace nil t) (require 'column-marker) (defvar cycle-whitespace-modes-state 0 "whitespace mode states: 0 -> no whitespace stuff, 1 -> highlighting of stray whitespace, 72 & 80 column lines 2 -> ws highlighting and identification for tabs and spaces (», ·)") (make-variable-buffer-local 'cycle-whitespace-modes-state) (defun my-cycle-whitespace-modes (&optional state) (interactive) (if state (setq cycle-whitespace-modes-state state) (setq cycle-whitespace-modes-state (mod (1+ cycle-whitespace-modes-state) 3))) (case cycle-whitespace-modes-state (0 (whitespace-mode 0) (column-marker-1 -2) (column-marker-2 -2) (column-marker-3 -2)) (1 (whitespace-mode 0) (whitespace-mode 1) (column-marker-1 72) (column-marker-2 80)) (otherwise (whitespace-mode 0) (whitespace-mode 1) (whitespace-toggle-options (list 'tab-mark 'space-mark)) (column-marker-1 72) (column-marker-2 80 (global-set-key [f10] 'my-cycle-whitespace-modes) (defun my-whitespace-modes-none () (my-cycle-whitespace-modes 0)) (defun my-whitespace-modes-some () (my-cycle-whitespace-modes 1)) (defun my-whitespace-modes-full () (my-cycle-whitespace-modes 2)) (add-hook 'c-mode-common-hook 'my-whitespace-modes-some) ;… ) 8<-->8 I usually have whitespace mode active in a medium warning level (my-whitespace-modes-some), which show whitespace at end of line etc. Sometimes, I want to see all spaces and tabs in a single buffer explicitly, e.g. for aligning stuff manually or debugging things (my-whitespace-modes-full). At other times, I want to deactivate all whitespace highlighting (my-whitespace-modes-none), e.g., when dealing with long lines or when crafting some ASCII drawings. I make, all of these decision per buffer. 2. Whitespace-mode is usually buffer local. Having it modify other buffers is irritating. If global effects are desired there is the variable whitespace-global-modes 3. (whitespace-toggle-options …) is documented to modify the local buffer only. Org's global display table de-localizes all of whitespace-mode's local functionality. Cheers, Martin - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
Hi Carsten, On 14.12.2009 17:27, Carsten Dominik wrote: > i can follow your arguments and would like to improve this. > > What I do not understand yet is this: > > I was under the impression that normally, there is only a single > display table in Emacs, and that is the global one and every buffer > will use it. Interesting, I had the opposite impression. I'm not exactly sure why though. Maybe from the documentation and name of the variable buffer-display-table? Maybe you had standard-display-table in mind? "Variable: Display table to use for buffers that specify none. See `buffer-display-table' for more information." I have, however, never seen a spelled out convention regarding deep sharing of display tables. > So it would seem to me that whitespace-mode would normally > *make* a local table in order to put its changes in there. However, > that does not seem to be the case here. Can you see why? I think whitespace-mode usually assumes that the local display tables is, well, local. Therefore, no action would be required. I forwarded my original bug-report to Vinicius Jose Latorre (whitespace-mode's maintainer) after you mentioned it would be a whitespace-mode bug. He replied: > Well, the problem was due to the way whitespace deal with > buffer-display-table variable. > > I've just fixed this problem in Emacs CVS and EmacsWiki. Here is the patch: http://lists.gnu.org/archive/html/emacs-diffs/2009-12/msg00184.html He basically creates a deep copy (the copy-sequence line) of the local display table and installs it. This should solve the problem. I still have this nagging feeling that the sharing of the display table is not the right thing to do and would regard the fix in whitespace-mode as a kind of emergence case backup. But this is probably purely a style thing. Thanks for getting back to me on this matter, Martin ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
On Dec 14, 2009, at 8:51 PM, Martin Pohlack wrote: Hi Carsten, On 14.12.2009 17:27, Carsten Dominik wrote: i can follow your arguments and would like to improve this. What I do not understand yet is this: I was under the impression that normally, there is only a single display table in Emacs, and that is the global one and every buffer will use it. Interesting, I had the opposite impression. I'm not exactly sure why though. Maybe from the documentation and name of the variable buffer-display-table? Maybe you had standard-display-table in mind? "Variable: Display table to use for buffers that specify none. See `buffer-display-table' for more information." I have, however, never seen a spelled out convention regarding deep sharing of display tables. So it would seem to me that whitespace-mode would normally *make* a local table in order to put its changes in there. However, that does not seem to be the case here. Can you see why? I think whitespace-mode usually assumes that the local display tables is, well, local. Therefore, no action would be required. I forwarded my original bug-report to Vinicius Jose Latorre (whitespace-mode's maintainer) after you mentioned it would be a whitespace-mode bug. He replied: Well, the problem was due to the way whitespace deal with buffer-display-table variable. I've just fixed this problem in Emacs CVS and EmacsWiki. Here is the patch: http://lists.gnu.org/archive/html/emacs-diffs/2009-12/msg00184.html He basically creates a deep copy (the copy-sequence line) of the local display table and installs it. This should solve the problem. I still have this nagging feeling that the sharing of the display table is not the right thing to do and would regard the fix in whitespace- mode as a kind of emergence case backup. But this is probably purely a style thing. And I do not agree here. Emacs has a global display tables that is normally shared across all buffers! So I would think it is perfectly OK to one that all buffers of a certain mode share. If whitespace.el intends to temporarily modify the display table of a particular buffer without affecting other, it must make sure that it does this correctly. In fact it did it already by making a local display table in order to avoid the global one. So the fix Vinicius implemented seems to be the correct solution. Thanks for getting back to me on this matter, Thank *you* for pursuing this! - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode