From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: Replace selective-display in Gnus Date: Sat, 29 Aug 2009 11:40:03 -0400 Message-ID: References: <200908290527.n7T5R7Na028106@godzilla.ics.uci.edu> <83bplzaxvm.fsf@gnu.org> <200908290732.n7T7WJTf029070@godzilla.ics.uci.edu> <87ljl381dq.fsf_-_@marauder.physik.uni-ulm.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1251560426 32488 80.91.229.12 (29 Aug 2009 15:40:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Aug 2009 15:40:26 +0000 (UTC) Cc: ding@gnus.org, emacs-devel@gnu.org To: Dan Nicolaescu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 29 17:40:19 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 1MhQ2K-0001vs-T8 for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2009 17:40:19 +0200 Original-Received: from localhost ([127.0.0.1]:42991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhQ2J-0001U0-SB for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2009 11:40:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MhQ2E-0001Tu-CG for emacs-devel@gnu.org; Sat, 29 Aug 2009 11:40:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MhQ29-0001Ti-MF for emacs-devel@gnu.org; Sat, 29 Aug 2009 11:40:10 -0400 Original-Received: from [199.232.76.173] (port=60948 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhQ29-0001Tf-JS for emacs-devel@gnu.org; Sat, 29 Aug 2009 11:40:05 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:32585 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MhQ29-0000ZG-1d for emacs-devel@gnu.org; Sat, 29 Aug 2009 11:40:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmYFACfpmEpFpYuS/2dsb2JhbACBU9R5hBoFgVWGE4Js X-IronPort-AV: E=Sophos;i="4.44,296,1249272000"; d="scan'208";a="44485918" Original-Received: from 69-165-139-146.dsl.teksavvy.com (HELO ceviche.home) ([69.165.139.146]) by ironport2-out.teksavvy.com with ESMTP; 29 Aug 2009 11:39:03 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id DCD55B40F3; Sat, 29 Aug 2009 11:40:03 -0400 (EDT) In-Reply-To: <87ljl381dq.fsf_-_@marauder.physik.uni-ulm.de> (Reiner Steib's message of "Sat, 29 Aug 2009 10:34:09 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) 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:114837 gmane.emacs.gnus.general:68936 Archived-At: > 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. I thought I had a few years back, but Google can't find it, so maybe I just dreamt it. Here is the gnus-sum.el code I'm using nowadays. IIRC it's not 100% correct (the behavior is not quite the same as the current one). This includes unrelated changes, and uses remove-overlays which was new in Emacs-22. Stefan Using submit branch file:///home/monnier/tmp/bzr/trunk/ === modified file 'lisp/gnus/gnus-sum.el' --- 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) @@ -3282,7 +3281,10 @@ '(progn (gnus-summary-skip-intangible) (or (get-text-property (point) 'gnus-number) - (gnus-summary-last-subject)))) + (gnus-summary-last-subject) + ;; FIXME: WTF? + ;; Triggered once from editing a text saved in the drafts folder. + (debug)))) (defmacro gnus-summary-article-header (&optional number) "Return the header of article NUMBER." @@ -4403,9 +4405,7 @@ (defsubst gnus-remove-odd-characters (string) "Translate STRING into something that doesn't contain weird characters." - (mm-subst-char-in-string - ?\r ?\- - (mm-subst-char-in-string ?\n ?\- string t) t)) + (replace-regexp-in-string "[\r\n]" "-" string)) ;; This function has to be called with point after the article number ;; on the beginning of the line. @@ -6101,8 +6101,7 @@ "Look through all the headers and mark the Xrefs as read." (let ((virtual (gnus-virtual-group-p from-newsgroup)) name info xref-hashtb idlist method nth4) - (save-excursion - (set-buffer gnus-group-buffer) + (with-current-buffer gnus-group-buffer (when (setq xref-hashtb (gnus-create-xref-hashtb from-newsgroup headers unreads)) (mapatoms @@ -7530,6 +7529,8 @@ (gnus-article-setup-buffer)) (gnus-set-global-variables) (with-current-buffer gnus-article-buffer + ;; It seems I added this at some point, not sure why. --Stef + ;; (let ((inhibit-read-only t)) (erase-buffer)) (setq gnus-article-charset gnus-newsgroup-charset) (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets) (mm-enable-multibyte)) @@ -9184,6 +9185,9 @@ (func `(lambda (h) (,(intern (concat "mail-header-" header)) h))) (case-fold-search t)) (dolist (header gnus-newsgroup-headers) + ;; FIXME: when called from gnus-summary-limit-include-thread via + ;; gnus-summary-limit-include-matching-articles, `regexp' is a decoded + ;; string whereas the header isn't decoded. (when (string-match regexp (funcall func header)) (push (mail-header-number header) articles))) (nreverse articles))) @@ -9845,7 +9849,7 @@ to-newsgroup select-method)) - ;;;!!!Why is this necessary? + ;;!!!Why is this necessary? (set-buffer gnus-summary-buffer) (gnus-summary-goto-subject article) @@ -10009,6 +10013,8 @@ (defun gnus-summary-expire-articles (&optional now) "Expire all articles that are marked as expirable in the current group." (interactive) + ;; (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) + ;; (error "Couldn't open server")) (when (and (not gnus-group-is-exiting-without-update-p) (gnus-check-backend-function 'request-expire-articles gnus-newsgroup-name)) @@ -10287,8 +10293,8 @@ ;; Prettify the article buffer again. (unless no-highlight (with-current-buffer gnus-article-buffer - ;;;!!! Fix this -- article should be rehighlighted. - ;;;(gnus-run-hooks 'gnus-article-display-hook) + ;;!!! Fix this -- article should be rehighlighted. + ;;(gnus-run-hooks 'gnus-article-display-hook) (set-buffer gnus-original-article-buffer) (gnus-request-article (cdr gnus-article-current) @@ -10450,8 +10456,8 @@ (set var (cons article (symbol-value var))) (if (memq type '(processable cached replied forwarded recent saved)) (gnus-summary-update-secondary-mark article) - ;;; !!! This is bogus. We should find out what primary - ;;; !!! mark we want to set. + ;; !!! This is bogus. We should find out what primary + ;; !!! mark we want to set. (gnus-summary-update-mark gnus-del-mark 'unread))))) (defun gnus-summary-mark-as-expirable (n) @@ -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. @@ -11854,8 +11863,12 @@ (and (boundp group) (symbol-name group) (symbol-value group) + ;; It seems that we may get spurious old groups which do not + ;; correspond to any server any more and for which the returned method + ;; is invalid (like (nil "")) and causes an error in gnus-get-function. + (ignore-errors (gnus-get-function (gnus-find-method-for-group - (symbol-name group)) 'request-accept-article t))) + (symbol-name group)) 'request-accept-article t)))) (defun gnus-read-move-group-name (prompt default articles prefix) "Read a group name."