emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Martin Pohlack <mp26@os.inf.tu-dresden.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis
Date: Mon, 14 Dec 2009 17:27:57 +0100	[thread overview]
Message-ID: <05105BC1-7F54-4439-BAAA-5065ACFC44C3@gmail.com> (raw)
In-Reply-To: <4B192DB9.6070407@os.inf.tu-dresden.de>

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

  reply	other threads:[~2009-12-14 17:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-02 19:02 Org-mode version 6.32trans and 6.21b; Strange interaction between whitespace-mode and cust. org-ellipsis Martin Pohlack
2009-12-03  8:20 ` Carsten Dominik
2009-12-03 21:34   ` Martin Pohlack
2009-12-04 12:26     ` Carsten Dominik
2009-12-04 15:41       ` Martin Pohlack
2009-12-14 16:27         ` Carsten Dominik [this message]
2009-12-14 19:51           ` Martin Pohlack
2010-01-01 13:34             ` Carsten Dominik
  -- strict thread matches above, loose matches on Subject: below --
2009-12-02 19:06 Martin Pohlack

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05105BC1-7F54-4439-BAAA-5065ACFC44C3@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mp26@os.inf.tu-dresden.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).