From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Getting rid of selective display in allout.el Date: Sun, 18 Dec 2005 19:00:09 -0500 Message-ID: <87irtmj6xh.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1134950542 22639 80.91.229.2 (19 Dec 2005 00:02:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 19 Dec 2005 00:02:22 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 19 01:02:12 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Eo8SP-0006qH-PE for ged-emacs-devel@m.gmane.org; Mon, 19 Dec 2005 01:00:50 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Eo8TC-0007Ls-KY for ged-emacs-devel@m.gmane.org; Sun, 18 Dec 2005 19:01:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Eo8Sj-0007KY-Qa for emacs-devel@gnu.org; Sun, 18 Dec 2005 19:01:13 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Eo8Sf-0007JJ-9C for emacs-devel@gnu.org; Sun, 18 Dec 2005 19:01:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Eo8Se-0007J9-NW for emacs-devel@gnu.org; Sun, 18 Dec 2005 19:01:04 -0500 Original-Received: from [209.226.175.74] (helo=tomts20-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Eo8VV-0005Ct-29 for emacs-devel@gnu.org; Sun, 18 Dec 2005 19:04:01 -0500 Original-Received: from alfajor ([65.92.242.250]) by tomts20-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20051219000010.DRBR8316.tomts20-srv.bellnexxia.net@alfajor>; Sun, 18 Dec 2005 19:00:10 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id E9264D7611; Sun, 18 Dec 2005 19:00:09 -0500 (EST) Original-To: Ken Manheimer User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-Originating-IP: [0] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:48018 Archived-At: Here is a 100% untested patch to allout.el that I expect to be a good start to getting rid of selective-display in allout.el. I don't have time to understand the code to really fix things properly, but that should give you enough of an idea. It took me at most 15min to come up with the patch below. It'd be great to get this finished and included in Emacs-22. Stefan --- allout.el 02 d=E9c 2005 14:04:20 -0500 1.64 +++ allout.el 18 d=E9c 2005 18:56:12 -0500=09 @@ -1465,7 +1465,7 @@ (progn (allout-resumptions 'allout-primary-bullet) (allout-resumptions 'allout-old-style-prefixes))) - (allout-resumptions 'selective-display) + (remove-from-invisibility-spec '(allout . t)) (if (and (boundp 'before-change-functions) before-change-functions) (allout-resumptions 'before-change-functions)) (set write-file-hook-var-name @@ -1528,7 +1528,7 @@ ; selective-display is the ; emacs conditional exposure ; mechanism: - (allout-resumptions 'selective-display '(t)) + (add-to-invisibility-spec '(allout . t)) (add-hook 'pre-command-hook 'allout-pre-command-business) (add-hook 'post-command-hook 'allout-post-command-business) (add-hook write-file-hook-var-name 'allout-write-file-hook-handler) @@ -1687,16 +1687,13 @@ (looking-at allout-regexp)) (=3D (point)(save-excursion (allout-end-of-prefix)(point))))) ;;;_ > allout-hidden-p () -(defmacro allout-hidden-p () +(defun allout-hidden-p () "True if point is in hidden text." - '(save-excursion - (and (re-search-backward "[\n\r]" () t) - (=3D ?\r (following-char))))) + (eq (get-char-property (point) 'invisible) 'allout)) ;;;_ > allout-visible-p () -(defmacro allout-visible-p () +(defun allout-visible-p () "True if point is not in hidden text." - (interactive) - '(not (allout-hidden-p))) + (not (allout-hidden-p))) ;;;_ : Location attributes ;;;_ > allout-depth () (defsubst allout-depth () @@ -1954,7 +1951,7 @@ (if further (setq result (append further result))) (setq chart (cdr chart))) (goto-char here) - (if (=3D (preceding-char) ?\r) + (if (allout-hidden-p) (setq result (cons here result))) (setq chart (cdr chart)))) result)) @@ -2922,7 +2919,8 @@ (if before (progn (end-of-line) (allout-pre-next-preface) - (while (=3D ?\r (following-char)) + (while (and (=3D ?\n (following-char)) + (allout-hidden-p)) (forward-char 1)) (if (not (looking-at "^$")) (allout-unprotected @@ -3741,53 +3739,18 @@ next C-j (newline) char. =20 Returns the endpoint of the region." - ;; "OFR-" prefixes to avoid collisions with vars in code calling the mac= ro. - ;; ie, elisp macro vars are not 'hygenic', so distinct names are necessa= ry. - (let ((was-inhibit-r-o inhibit-read-only) - (was-undo-list buffer-undo-list) - (was-modified (buffer-modified-p)) - trans) - (unwind-protect - (save-excursion - (setq inhibit-read-only t) - (setq buffer-undo-list t) - (if (> from to) - (setq trans from from to to trans)) - (subst-char-in-region from to - (if (=3D flag ?\n) ?\r ?\n) - flag t) - ;; adjust character read-protection on all the affected lines. - ;; we handle the region line-by-line. - (goto-char to) - (end-of-line) - (setq to (min (+ 2 (point)) (point-max))) + (if (> from to) (setq trans from from to to trans)) + (remove-overlays from to) + (when (eq flag ?\r) + (save-excursion (goto-char from) - (beginning-of-line) - (while (< (point) to) - ;; handle from start of exposed to beginning of hidden, or eol: - (remove-text-properties (point) - (progn (if (re-search-forward "[\r\n]" - nil t) - (forward-char -1)) - (point)) - '(read-only nil)) - ;; handle from start of hidden, if any, to eol: - (if (and (not (eobp)) (=3D (char-after (point)) ?\r)) - (put-text-property (point) (progn (end-of-line) (point)) - 'read-only t)) - ;; Handle the end-of-line to beginning of next line: - (if (not (eobp)) - (progn (forward-char 1) - (remove-text-properties (1- (point)) (point) - '(read-only nil))))) - ) - (if (not was-modified) - (set-buffer-modified-p nil)) - (setq inhibit-read-only was-inhibit-r-o) - (setq buffer-undo-list was-undo-list) - ) - ) - ) + (end-of-line) + (let ((ol (make-overlay (point) (progn (goto-char to) (end-of-line) = (point))))) + (overlay-put ol 'invisible 'allout) + ;; This won't work until we implement allout-isearch-open-invisibl= e. + (overlay-put ol 'isearch-open-invisible 'allout-isearch-open-invis= ible) + (overlay-put ol 'read-only t))))) + ;;;_ > allout-flag-current-subtree (flag) (defun allout-flag-current-subtree (flag) "Hide or show subtree of currently-visible topic. @@ -3815,7 +3778,7 @@ (let ((at (point)) beg end) (allout-goto-prefix) - (setq beg (if (=3D (preceding-char) ?\r) (1- (point)) (point))) + (setq beg (if (allout-hidden-p) (1- (point)) (point))) (re-search-forward "[\n\r]" nil t) (setq end (1- (if (< at (point)) ;; We're on topic head line - show only it: @@ -3859,7 +3822,7 @@ (chart (allout-chart-subtree (or level 1))) (to-reveal (allout-chart-to-reveal chart (or level 1)))) (goto-char start-pt) - (if (and strict (=3D (preceding-char) ?\r)) + (if (and strict (allout-hidden-p) ;; Concealed root would already have been taken care of, ;; unless strict was set. (progn @@ -3885,7 +3848,7 @@ (allout-goto-prefix) (allout-flag-region (if (not (bobp)) (1- (point)) (point)) (progn (allout-pre-next-preface) - (if (=3D ?\r (following-char)) + (if (allout-hidden-p) (point) (1- (point)))) ?\r))) @@ -3902,7 +3865,7 @@ (orig-pref (allout-goto-prefix)) (last-at (point)) bag-it) - (while (or bag-it (=3D (preceding-char) ?\r)) + (while (or bag-it (allout-hidden-p) (beginning-of-line) (if (=3D last-at (setq last-at (point))) ;; Oops, we're not making any progress! Show the current @@ -3954,7 +3917,7 @@ (allout-goto-prefix) (allout-flag-region (if (not (bobp)) (1- (point)) (point)) (progn (allout-pre-next-preface) - (if (=3D ?\r (following-char)) + (if (allout-hidden-p) (point) (1- (point)))) ?\r))) @@ -4423,7 +4386,7 @@ (save-excursion (end-of-line) (point)) 1) - (if (=3D (preceding-char) ?\r) + (if (allout-hidden-p) (1- (point)) (point)))) strings))