From: Reiner Steib <reinersteib+gmane@imap.cc>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Dan Nicolaescu <dann@ics.uci.edu>, ding@gnus.org, emacs-devel@gnu.org
Subject: Re: Replace selective-display in Gnus
Date: Sat, 29 Aug 2009 20:19:37 +0200 [thread overview]
Message-ID: <87skfa7a9y.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <jwvk50m3aea.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 29 Aug 2009 11:40:03 -0400")
On Sat, Aug 29 2009, Stefan Monnier wrote:
>> Could someone propose a patch how to use invisible overlays here? It
>> should be compatible with Emacs 21 (and up) and XEmacs 21.4 (and up)
>> if possible.
>
> Here is the gnus-sum.el code I'm using nowadays.
Thanks.
> IIRC it's not 100% correct (the behavior is not quite the same as
> the current one).
What is the difference? (I don't use this feature so I'll probably
won't notice it.)
> This includes unrelated changes, and uses remove-overlays which was
> new in Emacs-22.
As we need the old code for compatibility with older Emacsen, I think
I will install it with some (fboundp 'remove-overlays) conditionals.
Below are the relevant hunks (AFAICS) for review. Does anyone see a
problem with this?
--8<---------------cut here---------------start------------->8---
--- lisp/gnus/gnus-sum.el 2009-08-29 09:03:23 +0000
+++ lisp/gnus/gnus-sum.el 2009-08-29 14:14:56 +0000
@@ -3069,8 +3069,7 @@
(setq buffer-read-only t ;Disable modification
show-trailing-whitespace nil)
(setq truncate-lines t)
- (setq selective-display t)
- (setq selective-display-ellipses t) ;Display `...'
+ (add-to-invisibility-spec '(gnus-sum . t))
(gnus-summary-set-display-table)
(gnus-set-default-directory)
(make-local-variable 'gnus-summary-line-format)
@@ -11281,26 +11287,25 @@
(defun gnus-summary-show-all-threads ()
"Show all threads."
(interactive)
- (save-excursion
- (let ((buffer-read-only nil))
- (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
+ (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
(gnus-summary-position-point))
(defun gnus-summary-show-thread ()
"Show thread subtrees.
Returns nil if no thread was there to be shown."
(interactive)
- (let ((buffer-read-only nil)
- (orig (point))
+ (let* ((orig (point))
(end (point-at-eol))
;; Leave point at bol
- (beg (progn (beginning-of-line) (point))))
- (prog1
- ;; Any hidden lines here?
- (search-forward "\r" end t)
- (subst-char-in-region beg end ?\^M ?\n t)
+ (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
+ (eoi (when (eq (get-char-property end 'invisible) 'gnus-sum)
+ (or (next-single-char-property-change end 'invisible)
+ (point-max)))))
+ (when eoi
+ (remove-overlays beg eoi 'invisible 'gnus-sum)
(goto-char orig)
- (gnus-summary-position-point))))
+ (gnus-summary-position-point)
+ eoi)))
(defun gnus-summary-maybe-hide-threads ()
"If requested, hide the threads that should be hidden."
@@ -11349,22 +11354,26 @@
will not be hidden.
Returns nil if no threads were there to be hidden."
(interactive)
- (let ((buffer-read-only nil)
- (start (point))
+ (let ((start (point))
+ (starteol (line-end-position))
(article (gnus-summary-article-number)))
(goto-char start)
;; Go forward until either the buffer ends or the subthread ends.
(when (and (not (eobp))
(or (zerop (gnus-summary-next-thread 1 t))
(goto-char (point-max))))
- (prog1
(if (and (> (point) start)
+ ;; FIXME: this should actually search for a non-invisible \n.
(search-backward "\n" start t))
(progn
- (subst-char-in-region start (point) ?\n ?\^M)
+ (when (> (point) starteol)
+ (remove-overlays starteol (point) 'invisible 'gnus-sum)
+ (let ((ol (make-overlay starteol (point) nil t nil)))
+ (overlay-put ol 'invisible 'gnus-sum)
+ (overlay-put ol 'evaporate t)))
(gnus-summary-goto-subject article))
(goto-char start)
- nil)))))
+ nil))))
(defun gnus-summary-go-to-next-thread (&optional previous)
"Go to the same level (or less) next thread.
--8<---------------cut here---------------end--------------->8---
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
next prev parent reply other threads:[~2009-08-29 18:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-29 5:27 obsolete selective-display ? Dan Nicolaescu
2009-08-29 7:21 ` Eli Zaretskii
2009-08-29 7:32 ` Dan Nicolaescu
2009-08-29 7:49 ` Eli Zaretskii
2009-08-29 15:44 ` Stefan Monnier
2009-08-29 7:50 ` Miles Bader
2009-08-29 8:34 ` Replace selective-display in Gnus (was: obsolete selective-display ?) Reiner Steib
2009-08-29 15:40 ` Replace selective-display in Gnus Stefan Monnier
2009-08-29 18:19 ` Reiner Steib [this message]
2009-08-29 18:26 ` Dan Nicolaescu
2009-10-14 19:05 ` Reiner Steib
2009-10-15 1:01 ` Katsumi Yamaoka
2009-10-15 4:34 ` Stephen J. Turnbull
2009-10-16 7:06 ` Katsumi Yamaoka
2009-10-17 10:41 ` Reiner Steib
2009-10-18 23:51 ` Katsumi Yamaoka
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87skfa7a9y.fsf@marauder.physik.uni-ulm.de \
--to=reinersteib+gmane@imap.cc \
--cc=Reiner.Steib@gmx.de \
--cc=dann@ics.uci.edu \
--cc=ding@gnus.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.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).