From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Reiner Steib Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: Replace selective-display in Gnus Date: Sat, 29 Aug 2009 20:19:37 +0200 Message-ID: <87skfa7a9y.fsf@marauder.physik.uni-ulm.de> References: <200908290527.n7T5R7Na028106@godzilla.ics.uci.edu> <83bplzaxvm.fsf@gnu.org> <200908290732.n7T7WJTf029070@godzilla.ics.uci.edu> <87ljl381dq.fsf_-_@marauder.physik.uni-ulm.de> Reply-To: Reiner Steib NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1251570004 24554 80.91.229.12 (29 Aug 2009 18:20:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Aug 2009 18:20:04 +0000 (UTC) Cc: Dan Nicolaescu , ding@gnus.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 29 20:19:56 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MhSWp-0006z6-QO for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2009 20:19:56 +0200 Original-Received: from localhost ([127.0.0.1]:56235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhSWo-0002TJ-Pd for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2009 14:19:54 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MhSWi-0002Rx-8S for emacs-devel@gnu.org; Sat, 29 Aug 2009 14:19:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MhSWd-0002Qg-CV for emacs-devel@gnu.org; Sat, 29 Aug 2009 14:19:47 -0400 Original-Received: from [199.232.76.173] (port=37772 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhSWd-0002Qa-2A for emacs-devel@gnu.org; Sat, 29 Aug 2009 14:19:43 -0400 Original-Received: from mail.uni-ulm.de ([134.60.1.11]:57642) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MhSWc-0004KL-EM for emacs-devel@gnu.org; Sat, 29 Aug 2009 14:19:42 -0400 Original-Received: from bridgekeeper.physik.uni-ulm.de (bridgekeeper.physik.uni-ulm.de [134.60.10.175]) by mail.uni-ulm.de (8.14.2/8.14.2) with ESMTP id n7TIJckO008157; Sat, 29 Aug 2009 20:19:38 +0200 (MEST) Original-Received: from localhost (localhost [127.0.0.1]) by bridgekeeper.physik.uni-ulm.de (Postfix) with ESMTP id 0EA3F1CE66; Sat, 29 Aug 2009 20:19:38 +0200 (CEST) X-Face: /U7=m^"/-Dn61mAl{g9e3>\G5Tp,oEX|V)g2I1hBk\ML; )7A?6cmB-y7y?'NA^J<=oz7syB =(McAwIHgLX!.B?R3X}98d@?>CrT094KLWh]WU4gDpnL/")MS(XoQTv`Oq225uL>+; CpPXo$N5e>N> $tPd-gbB^F{gQS#1ase]XO~D4p4M"3+F-7~u]dy3I?Pb8RO*H-EFeWDUf?Rf, d]pv\Jvh2Cht!A=im yKAS2Z%Ao^;}W/qzMvMm Mail-Followup-To: Stefan Monnier , Dan Nicolaescu , ding@gnus.org, emacs-devel@gnu.org In-Reply-To: (Stefan Monnier's message of "Sat, 29 Aug 2009 11:40:03 -0400") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.1 (gnu/linux) X-DCC-CTc-dcc2-Metrics: poseidon 1031; Body=4 Fuz1=4 Fuz2=4 X-Virus-Scanned: by amavisd-new X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:114842 gmane.emacs.gnus.general:68938 Archived-At: 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/