[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposed new minor mode

From: Luc Teirlinck
Subject: Proposed new minor mode
Date: Fri, 6 Jun 2003 20:51:10 -0500 (CDT)

I propose to add the following new minor mode to Emacs.  Direct
motivation is Info, where I propose to bind it to `i', but it could be
used elsewhere.

It makes all invisible text visible, after saving the old value of
buffer-invisibility-spec.  Disabling the minor mode restores the old
value.  Switching major modes automatically disables, because the new
major mode might want to set its own value of

The main motivation is that killing and yanking, saving to file,
copying parts of the buffer to file, mailing, printing, make all
invisible text visible.  It is good to let the user see which text he
really is going to yank, save or copy to file, mail, print and so on.
Also, to allow him to figure why various commands like M-x man, C-h f
and the like might be behaving strangely.  Also to allow him to edit
in a way that he really knows what he is editing.  

This is not meant as a substitute for similar commands in specialized
modes, say outline mode, which should have commands to make only the
text they made invisible back visible.

A good place to try it out would be the dir file in info.  Doing so
will also show that there are still some problems with Stefan's new
node hiding implementation.  I believe these problems can be fixed.  I
will go into that separately.

I would not know in which file exactly the stuff would need to go.
Info is the main motivation, but it is much more general.

===File ~/vis-mode.el=======================================
(make-variable-buffer-local 'saved-buffer-invisibility-spec)

(defvar saved-buffer-invisibility-spec nil
  "Saved value of buffer-invisibility-spec when `vis-mode' is on.")

;; The next function is needed for use in change-major-mode-hook.
(defun vis-mode-disable ()
  "Disable vis-mode."
  (vis-mode 0))

(define-minor-mode vis-mode
  "Toggle vis-mode.
With argument ARG turn vis-mode on iff ARG is positive..

Enabling vis-mode sets `buffer-invisibility-spec' to nil, after
saving the old value in the variable
`saved-buffer-invisibility-spec', making all invisible text in
the buffer visible.

Disabling vis-mode restores the saved value of

Cannging the major mode always disables vis-mode"
  :lighter " Vis"
  (if vis-mode
        (setq saved-buffer-invisibility-spec buffer-invisibility-spec
              buffer-invisibility-spec nil)
        (add-hook 'change-major-mode-hook 'vis-mode-disable nil t))
    (setq buffer-invisibility-spec saved-buffer-invisibility-spec
          saved-buffer-invisibility-spec nil)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]