[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hide local variables in enriched mode
From: |
drkm |
Subject: |
Re: hide local variables in enriched mode |
Date: |
Wed, 12 Jan 2005 04:18:29 +0100 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (windows-nt) |
Pascal Bourguignon <spam@mouse-potato.com> writes:
> I'd try to narrow the region before ps-printing.
Yes.
> This could be done automatically with something like:
> -*- mode: fileadapt -*-
> blah blah blah
> Local Variables:
> eval: (let ((start (progn (beginning-of-buffer) (forward-line 2) (point)))
> (end ((end-of-buffer) (re-search-backward "Local Variables") (forward-line
> -1) (point)))) (narrow-to-region start end))
> End:
You forgot a "progn" before "end-of-buffer", I guess.
> (Of course, you could define a function in ~/.emacs and use it in
> eval: in place of this complex expression.)
I think the "eval" pseudo-local variable is annoying. Because Emacs
ask you every time you open the file. What do you think about
something like this:
(defun sk:hide-local-variables ()
(narrow-to-region (point-min)
(progn
(end-of-buffer)
;; TODO: Set the BOUND arg.
(re-search-backward "Local Variables" nil t)
(forward-line -1)
(point))))
(defadvice ps-print-buffer
(around sk:ps-print-buffer activate)
"FIXME:..."
(save-excursion
(save-restriction
(sk:hide-local-variables)
ad-do-it)))
(defadvice ps-print-buffer-with-faces
(around sk:ps-print-buffer-with-faces activate)
"FIXME:..."
(save-excursion
(save-restriction
(sk:hide-local-variables)
ad-do-it)))
(defadvice ps-spool-buffer
(around sk:ps-spool-buffer activate)
"FIXME:..."
(save-excursion
(save-restriction
(sk:hide-local-variables)
ad-do-it)))
(defadvice ps-spool-buffer-with-faces
(around sk:ps-spool-buffer-with-faces activate)
"FIXME:..."
(save-excursion
(save-restriction
(sk:hide-local-variables)
ad-do-it)))
If you want to say with a local variables to narrow or not, you can
change the advices like this:
(defvar sk:ps-hide-local-variables nil
"FIXME:...")
(defadvice ps-print-buffer
(around sk:ps-print-buffer activate)
"FIXME:..."
(save-excursion
(save-restriction
(when sk:ps-hide-local-variables
(sk:hide-local-variables))
ad-do-it)))
;; and the like ...
and put this in your file:
;; Local Variables
;; sk:ps-hide-local-variables: t
;; End
What do you think about this?
--drkm, que, finalement, fcae est chouette, aussi ;-)