aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShengHuo ZHU2000-12-20 06:13:15 +0000
committerShengHuo ZHU2000-12-20 06:13:15 +0000
commit520aa572f807e467e59285f9bed2f7ac66c3de31 (patch)
treec1713bed60253f7beeb8646a120b7746cd74b456
parent09877d5d2fe7feed2fd697d0bb4c92dc61c18eba (diff)
downloademacs-520aa572f807e467e59285f9bed2f7ac66c3de31.tar.gz
emacs-520aa572f807e467e59285f9bed2f7ac66c3de31.zip
* gnus-util.el (gnus-add-text-properties-when): New function.
(gnus-remove-text-properties-when): Ditto. * gnus-cite.el (gnus-article-hide-citation): Use them. (gnus-article-toggle-cited-text): Use them. * gnus-art.el (gnus-signature-toggle): Use them. (gnus-article-show-hidden-text): Ditto. (gnus-article-hide-text): Ditto. * gnus-art.el (gnus-article-describe-key): Use prompt. (gnus-article-describe-key-briefly): Ditto.
-rw-r--r--lisp/gnus/ChangeLog15
-rw-r--r--lisp/gnus/gnus-art.el111
-rw-r--r--lisp/gnus/gnus-cite.el161
-rw-r--r--lisp/gnus/gnus-util.el22
4 files changed, 197 insertions, 112 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 00f5cb5b345..326d346b9a8 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,18 @@
12000-12-20 ShengHuo ZHU <zsh@cs.rochester.edu>
2
3 * gnus-util.el (gnus-add-text-properties-when): New function.
4 (gnus-remove-text-properties-when): Ditto.
5
6 * gnus-cite.el (gnus-article-hide-citation): Use them.
7 (gnus-article-toggle-cited-text): Use them.
8
9 * gnus-art.el (gnus-signature-toggle): Use them.
10 (gnus-article-show-hidden-text): Ditto.
11 (gnus-article-hide-text): Ditto.
12
13 * gnus-art.el (gnus-article-describe-key): Use prompt.
14 (gnus-article-describe-key-briefly): Ditto.
15
12000-12-19 ShengHuo ZHU <zsh@cs.rochester.edu> 162000-12-19 ShengHuo ZHU <zsh@cs.rochester.edu>
2 17
3 * mm-util.el (mm-charset-synonym-alist): Fix a typo. 18 * mm-util.el (mm-charset-synonym-alist): Fix a typo.
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 517a16d745a..c1d7a62df57 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -1053,11 +1053,12 @@ Initialized from `text-mode-syntax-table.")
1053 1053
1054(defsubst gnus-article-hide-text (b e props) 1054(defsubst gnus-article-hide-text (b e props)
1055 "Set text PROPS on the B to E region, extending `intangible' 1 past B." 1055 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1056 (add-text-properties b e props) 1056 (gnus-add-text-properties-when 'article-type nil b e props)
1057 (when (memq 'intangible props) 1057 (when (memq 'intangible props)
1058 (put-text-property 1058 (put-text-property
1059 (max (1- b) (point-min)) 1059 (max (1- b) (point-min))
1060 b 'intangible (cddr (memq 'intangible props))))) 1060 b 'intangible (cddr (memq 'intangible props)))))
1061
1061(defsubst gnus-article-unhide-text (b e) 1062(defsubst gnus-article-unhide-text (b e)
1062 "Remove hidden text properties from region between B and E." 1063 "Remove hidden text properties from region between B and E."
1063 (remove-text-properties b e gnus-hidden-properties) 1064 (remove-text-properties b e gnus-hidden-properties)
@@ -1976,24 +1977,16 @@ means show, 0 means toggle."
1976 'hidden 1977 'hidden
1977 nil))) 1978 nil)))
1978 1979
1979(defun gnus-article-show-hidden-text (type &optional hide) 1980(defun gnus-article-show-hidden-text (type &optional dummy)
1980 "Show all hidden text of type TYPE. 1981 "Show all hidden text of type TYPE.
1981If HIDE, hide the text instead." 1982Originally it is hide instead of DUMMY."
1982 (save-excursion 1983 (let ((buffer-read-only nil)
1983 (let ((buffer-read-only nil) 1984 (inhibit-point-motion-hooks t))
1984 (inhibit-point-motion-hooks t) 1985 (gnus-remove-text-properties-when
1985 (end (point-min)) 1986 'article-type type
1986 beg) 1987 (point-min) (point-max)
1987 (while (setq beg (text-property-any end (point-max) 'article-type type)) 1988 (cons 'article-type (cons type
1988 (goto-char beg) 1989 gnus-hidden-properties)))))
1989 (setq end (or
1990 (text-property-not-all beg (point-max) 'article-type type)
1991 (point-max)))
1992 (if hide
1993 (gnus-article-hide-text beg end gnus-hidden-properties)
1994 (gnus-article-unhide-text beg end))
1995 (goto-char end))
1996 t)))
1997 1990
1998(defconst article-time-units 1991(defconst article-time-units
1999 `((year . ,(* 365.25 24 60 60)) 1992 `((year . ,(* 365.25 24 60 60))
@@ -2639,6 +2632,8 @@ If variable `gnus-use-long-file-name' is non-nil, it is
2639 ">" end-of-buffer 2632 ">" end-of-buffer
2640 "\C-c\C-i" gnus-info-find-node 2633 "\C-c\C-i" gnus-info-find-node
2641 "\C-c\C-b" gnus-bug 2634 "\C-c\C-b" gnus-bug
2635 "\C-hk" gnus-article-describe-key
2636 "\C-hc" gnus-article-describe-key-briefly
2642 2637
2643 "\C-d" gnus-article-read-summary-keys 2638 "\C-d" gnus-article-read-summary-keys
2644 "\M-*" gnus-article-read-summary-keys 2639 "\M-*" gnus-article-read-summary-keys
@@ -3836,26 +3831,58 @@ Argument LINES specifies lines to be scrolled down."
3836 (switch-to-buffer summary 'norecord)) 3831 (switch-to-buffer summary 'norecord))
3837 (setq in-buffer (current-buffer)) 3832 (setq in-buffer (current-buffer))
3838 ;; We disable the pick minor mode commands. 3833 ;; We disable the pick minor mode commands.
3839 (if (setq func (let (gnus-pick-mode) 3834 (if (and (setq func (let (gnus-pick-mode)
3840 (lookup-key (current-local-map) keys))) 3835 (lookup-key (current-local-map) keys)))
3836 (functionp func))
3841 (progn 3837 (progn
3842 (call-interactively func) 3838 (call-interactively func)
3843 (setq new-sum-point (point))) 3839 (setq new-sum-point (point))
3844 (ding)) 3840 (when (eq in-buffer (current-buffer))
3845 (when (eq in-buffer (current-buffer)) 3841 (setq selected (gnus-summary-select-article))
3846 (setq selected (gnus-summary-select-article)) 3842 (set-buffer obuf)
3847 (set-buffer obuf) 3843 (unless not-restore-window
3848 (unless not-restore-window 3844 (set-window-configuration owin))
3849 (set-window-configuration owin)) 3845 (when (eq selected 'old)
3850 (when (eq selected 'old) 3846 (article-goto-body)
3851 (article-goto-body) 3847 (set-window-start (get-buffer-window (current-buffer))
3852 (set-window-start (get-buffer-window (current-buffer)) 3848 1)
3853 1) 3849 (set-window-point (get-buffer-window (current-buffer))
3854 (set-window-point (get-buffer-window (current-buffer)) 3850 (point)))
3855 (point))) 3851 (let ((win (get-buffer-window gnus-article-current-summary)))
3856 (let ((win (get-buffer-window gnus-article-current-summary))) 3852 (when win
3857 (when win 3853 (set-window-point win new-sum-point)))) )
3858 (set-window-point win new-sum-point)))))))) 3854 (switch-to-buffer gnus-article-buffer)
3855 (ding))))))
3856
3857(defun gnus-article-describe-key (key)
3858 "Display documentation of the function invoked by KEY. KEY is a string."
3859 (interactive "kDescribe key: ")
3860 (gnus-article-check-buffer)
3861 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3862 (save-excursion
3863 (set-buffer gnus-article-current-summary)
3864 (let (gnus-pick-mode)
3865 (push (elt key 0) unread-command-events)
3866 (setq key (if (featurep 'xemacs)
3867 (events-to-keys (read-key-sequence "Describe key: "))
3868 (read-key-sequence "Describe key: "))))
3869 (describe-key key))
3870 (describe-key key)))
3871
3872(defun gnus-article-describe-key-briefly (key &optional insert)
3873 "Display documentation of the function invoked by KEY. KEY is a string."
3874 (interactive "kDescribe key: \nP")
3875 (gnus-article-check-buffer)
3876 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3877 (save-excursion
3878 (set-buffer gnus-article-current-summary)
3879 (let (gnus-pick-mode)
3880 (push (elt key 0) unread-command-events)
3881 (setq key (if (featurep 'xemacs)
3882 (events-to-keys (read-key-sequence "Describe key: "))
3883 (read-key-sequence "Describe key: "))))
3884 (describe-key-briefly key insert))
3885 (describe-key-briefly key insert)))
3859 3886
3860(defun gnus-article-hide (&optional arg force) 3887(defun gnus-article-hide (&optional arg force)
3861 "Hide all the gruft in the current article. 3888 "Hide all the gruft in the current article.
@@ -4509,9 +4536,15 @@ specified by `gnus-button-alist'."
4509 (set-buffer gnus-article-buffer) 4536 (set-buffer gnus-article-buffer)
4510 (let ((buffer-read-only nil) 4537 (let ((buffer-read-only nil)
4511 (inhibit-point-motion-hooks t)) 4538 (inhibit-point-motion-hooks t))
4512 (if (get-text-property end 'invisible) 4539 (if (text-property-any end (point-max) 'article-type 'signature)
4513 (gnus-article-unhide-text end (point-max)) 4540 (gnus-remove-text-properties-when
4514 (gnus-article-hide-text end (point-max) gnus-hidden-properties))))) 4541 'article-type 'signature end (point-max)
4542 (cons 'article-type (cons 'signature
4543 gnus-hidden-properties)))
4544 (gnus-add-text-properties-when
4545 'article-type nil end (point-max)
4546 (cons 'article-type (cons 'signature
4547 gnus-hidden-properties)))))))
4515 4548
4516(defun gnus-button-entry () 4549(defun gnus-button-entry ()
4517 ;; Return the first entry in `gnus-button-alist' matching this place. 4550 ;; Return the first entry in `gnus-button-alist' matching this place.
diff --git a/lisp/gnus/gnus-cite.el b/lisp/gnus/gnus-cite.el
index fcddb0b76fa..ef659175b14 100644
--- a/lisp/gnus/gnus-cite.el
+++ b/lisp/gnus/gnus-cite.el
@@ -468,57 +468,63 @@ always hide."
468 (gnus-set-format 'cited-closed-text-button t) 468 (gnus-set-format 'cited-closed-text-button t)
469 (save-excursion 469 (save-excursion
470 (set-buffer gnus-article-buffer) 470 (set-buffer gnus-article-buffer)
471 (cond
472 ((gnus-article-check-hidden-text 'cite arg)
473 t)
474 ((gnus-article-text-type-exists-p 'cite)
475 (let ((buffer-read-only nil))
476 (gnus-article-hide-text-of-type 'cite)))
477 (t
478 (let ((buffer-read-only nil) 471 (let ((buffer-read-only nil)
479 (marks (gnus-dissect-cited-text)) 472 marks
480 (inhibit-point-motion-hooks t) 473 (inhibit-point-motion-hooks t)
481 (props (nconc (list 'article-type 'cite) 474 (props (nconc (list 'article-type 'cite)
482 gnus-hidden-properties)) 475 gnus-hidden-properties))
483 beg end start) 476 (point (point-min))
484 (while marks 477 found beg end start)
485 (setq beg nil 478 (while (setq point
486 end nil) 479 (text-property-any point (point-max)
487 (while (and marks (string= (cdar marks) "")) 480 'gnus-callback
488 (setq marks (cdr marks))) 481 'gnus-article-toggle-cited-text))
489 (when marks 482 (setq found t)
490 (setq beg (caar marks))) 483 (goto-char point)
491 (while (and marks (not (string= (cdar marks) ""))) 484 (gnus-article-toggle-cited-text
492 (setq marks (cdr marks))) 485 (get-text-property point 'gnus-data) arg)
493 (when marks 486 (forward-line 1)
487 (setq point (point)))
488 (unless found
489 (setq marks (gnus-dissect-cited-text))
490 (while marks
491 (setq beg nil
492 end nil)
493 (while (and marks (string= (cdar marks) ""))
494 (setq marks (cdr marks)))
495 (when marks
496 (setq beg (caar marks)))
497 (while (and marks (not (string= (cdar marks) "")))
498 (setq marks (cdr marks)))
499 (when marks
494 (setq end (caar marks))) 500 (setq end (caar marks)))
495 ;; Skip past lines we want to leave visible. 501 ;; Skip past lines we want to leave visible.
496 (when (and beg end gnus-cited-lines-visible) 502 (when (and beg end gnus-cited-lines-visible)
497 (goto-char beg) 503 (goto-char beg)
498 (forward-line (if (consp gnus-cited-lines-visible) 504 (forward-line (if (consp gnus-cited-lines-visible)
499 (car gnus-cited-lines-visible) 505 (car gnus-cited-lines-visible)
500 gnus-cited-lines-visible)) 506 gnus-cited-lines-visible))
501 (if (>= (point) end) 507 (if (>= (point) end)
502 (setq beg nil) 508 (setq beg nil)
503 (setq beg (point-marker)) 509 (setq beg (point-marker))
504 (when (consp gnus-cited-lines-visible) 510 (when (consp gnus-cited-lines-visible)
505 (goto-char end) 511 (goto-char end)
506 (forward-line (- (cdr gnus-cited-lines-visible))) 512 (forward-line (- (cdr gnus-cited-lines-visible)))
507 (if (<= (point) beg) 513 (if (<= (point) beg)
508 (setq beg nil) 514 (setq beg nil)
509 (setq end (point-marker)))))) 515 (setq end (point-marker))))))
510 (when (and beg end) 516 (when (and beg end)
511 ;; We use markers for the end-points to facilitate later 517 ;; We use markers for the end-points to facilitate later
512 ;; wrapping and mangling of text. 518 ;; wrapping and mangling of text.
513 (setq beg (set-marker (make-marker) beg) 519 (setq beg (set-marker (make-marker) beg)
514 end (set-marker (make-marker) end)) 520 end (set-marker (make-marker) end))
515 (gnus-add-text-properties beg end props) 521 (gnus-add-text-properties-when 'article-type nil beg end props)
516 (goto-char beg) 522 (goto-char beg)
517 (unless (save-excursion (search-backward "\n\n" nil t)) 523 (unless (save-excursion (search-backward "\n\n" nil t))
518 (insert "\n")) 524 (insert "\n"))
519 (put-text-property 525 (put-text-property
520 (setq start (point-marker)) 526 (setq start (point-marker))
521 (progn 527 (progn
522 (gnus-article-add-button 528 (gnus-article-add-button
523 (point) 529 (point)
524 (progn (eval gnus-cited-closed-text-button-line-format-spec) 530 (progn (eval gnus-cited-closed-text-button-line-format-spec)
@@ -526,42 +532,51 @@ always hide."
526 `gnus-article-toggle-cited-text 532 `gnus-article-toggle-cited-text
527 (list (cons beg end) start)) 533 (list (cons beg end) start))
528 (point)) 534 (point))
529 'article-type 'annotation) 535 'article-type 'annotation)
530 (set-marker beg (point))))))))) 536 (set-marker beg (point))))))))
531 537
532(defun gnus-article-toggle-cited-text (args) 538(defun gnus-article-toggle-cited-text (args &optional arg)
533 "Toggle hiding the text in REGION." 539 "Toggle hiding the text in REGION.
540ARG can be nil or a number. Positive means hide, negative
541means show, nil means toggle."
534 (let* ((region (car args)) 542 (let* ((region (car args))
535 (beg (car region)) 543 (beg (car region))
536 (end (cdr region)) 544 (end (cdr region))
537 (start (cadr args)) 545 (start (cadr args))
538 (hidden 546 (hidden
539 (text-property-any 547 (text-property-any beg (1- end) 'article-type 'cite))
540 beg (1- end)
541 (car gnus-hidden-properties) (cadr gnus-hidden-properties)))
542 (inhibit-point-motion-hooks t) 548 (inhibit-point-motion-hooks t)
543 buffer-read-only) 549 buffer-read-only)
544 (funcall 550 (when (or (null arg)
545 (if hidden 551 (zerop arg)
546 'remove-text-properties 'gnus-add-text-properties) 552 (and (> arg 0) (not hidden))
547 beg end gnus-hidden-properties) 553 (and (< arg 0) hidden))
548 (save-excursion 554 (if hidden
549 (goto-char start) 555 (gnus-remove-text-properties-when
550 (gnus-delete-line) 556 'article-type 'cite beg end
551 (put-text-property 557 (cons 'article-type (cons 'cite
552 (point) 558 gnus-hidden-properties)))
553 (progn 559 (gnus-add-text-properties-when
554 (gnus-article-add-button 560 'article-type nil beg end
555 (point) 561 (cons 'article-type (cons 'cite
556 (progn (eval 562 gnus-hidden-properties))))
557 (if hidden 563 (save-excursion
558 gnus-cited-opened-text-button-line-format-spec 564 (goto-char start)
559 gnus-cited-closed-text-button-line-format-spec)) 565 (gnus-delete-line)
560 (point)) 566 (put-text-property
561 `gnus-article-toggle-cited-text 567 (point)
562 args) 568 (progn
563 (point)) 569 (gnus-article-add-button
564 'article-type 'annotation)))) 570 (point)
571 (progn (eval
572 (if hidden
573 gnus-cited-opened-text-button-line-format-spec
574 gnus-cited-closed-text-button-line-format-spec))
575 (point))
576 `gnus-article-toggle-cited-text
577 args)
578 (point))
579 'article-type 'annotation)))))
565 580
566(defun gnus-article-hide-citation-maybe (&optional arg force) 581(defun gnus-article-hide-citation-maybe (&optional arg force)
567 "Toggle hiding of cited text that has an attribution line. 582 "Toggle hiding of cited text that has an attribution line.
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 0e037154d05..8fa0068b085 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -974,6 +974,28 @@ Entries without port tokens default to DEFAULTPORT."
974 (while (search-backward "\\." nil t) 974 (while (search-backward "\\." nil t)
975 (delete-char 1))))) 975 (delete-char 1)))))
976 976
977(defun gnus-add-text-properties-when
978 (property value start end properties &optional object)
979 "Like `gnus-add-text-properties', only applied on where PROPERTY is VALUE."
980 (let (point)
981 (while (and start
982 (setq point (text-property-not-all start end property value)))
983 (gnus-add-text-properties start point properties object)
984 (setq start (text-property-any point end property value)))
985 (if start
986 (gnus-add-text-properties start end properties object))))
987
988(defun gnus-remove-text-properties-when
989 (property value start end properties &optional object)
990 "Like `remove-text-properties', only applied on where PROPERTY is VALUE."
991 (let (point)
992 (while (and start
993 (setq point (text-property-not-all start end property value)))
994 (remove-text-properties start point properties object)
995 (setq start (text-property-any point end property value)))
996 (if start
997 (remove-text-properties start end properties object))))
998
977(provide 'gnus-util) 999(provide 'gnus-util)
978 1000
979;;; gnus-util.el ends here 1001;;; gnus-util.el ends here