aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2012-12-11 19:57:48 +0100
committerJoakim Verona2012-12-11 19:57:48 +0100
commitb24b248771c6c8391fd252592e78ae316deb86cb (patch)
tree5e396e6802c602a1f630b0260edbea818845d889
parent3969dbed6bfc1aa505210e36839a81a2bb41ebdb (diff)
parent030f4af55bc3ce886c3dab85cd3d4a988dcb93f6 (diff)
downloademacs-b24b248771c6c8391fd252592e78ae316deb86cb.tar.gz
emacs-b24b248771c6c8391fd252592e78ae316deb86cb.zip
auto upstream
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/button.el13
-rw-r--r--lisp/hilit-chg.el88
-rw-r--r--lisp/mail/emacsbug.el30
4 files changed, 66 insertions, 79 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 17dc012fdab..d6d7b18955e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12012-12-11 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * mail/emacsbug.el (report-emacs-bug): Move the intangible text to
4 a display text-property.
5 (report-emacs-bug-hook): Don't bother deleting it any more.
6
7 * hilit-chg.el (highlight-save-buffer-state): Delete.
8 Use with-silent-modifications instead.
9 (hilit-chg-set-face-on-change): Only fixup the text that's modified.
10
11 * button.el: Handle buttons in display text-properties.
12 (button--area-button-p, button--area-button-string):
13 Use (STRING . STRING-POS) representation instead of just STRING.
14
12012-12-11 Eli Zaretskii <eliz@gnu.org> 152012-12-11 Eli Zaretskii <eliz@gnu.org>
2 16
3 * makefile.w32-in (compile4-SH): Fix a typo that caused term 17 * makefile.w32-in (compile4-SH): Fix a typo that caused term
diff --git a/lisp/button.el b/lisp/button.el
index c52dcabed08..f15f09f24db 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -192,7 +192,8 @@ changes to a supertype are not reflected in its subtypes)."
192 (cond ((overlayp button) 192 (cond ((overlayp button)
193 (overlay-get button prop)) 193 (overlay-get button prop))
194 ((button--area-button-p button) 194 ((button--area-button-p button)
195 (get-text-property 0 prop (button--area-button-string button))) 195 (get-text-property (cdr button)
196 prop (button--area-button-string button)))
196 (t ; Must be a text-property button. 197 (t ; Must be a text-property button.
197 (get-text-property button prop)))) 198 (get-text-property button prop))))
198 199
@@ -257,11 +258,11 @@ header-line) a string."
257 "Return t if BUTTON has button-type TYPE, or one of TYPE's subtypes." 258 "Return t if BUTTON has button-type TYPE, or one of TYPE's subtypes."
258 (button-type-subtype-p (button-get button 'type) type)) 259 (button-type-subtype-p (button-get button 'type) type))
259 260
260(defalias 'button--area-button-p 'stringp 261(defun button--area-button-p (b) (stringp (car-safe b))
261 "Return non-nil if BUTTON is an area button. 262 "Return non-nil if BUTTON is an area button.
262Such area buttons are used for buttons in the mode-line and header-line.") 263Such area buttons are used for buttons in the mode-line and header-line.")
263 264
264(defalias 'button--area-button-string 'identity 265(defalias 'button--area-button-string #'car
265 "Return area button BUTTON's button-string.") 266 "Return area button BUTTON's button-string.")
266 267
267;; Creating overlay buttons 268;; Creating overlay buttons
@@ -444,9 +445,9 @@ return t."
444 ;; POS is a mouse event; switch to the proper window/buffer 445 ;; POS is a mouse event; switch to the proper window/buffer
445 (let ((posn (event-start pos))) 446 (let ((posn (event-start pos)))
446 (with-current-buffer (window-buffer (posn-window posn)) 447 (with-current-buffer (window-buffer (posn-window posn))
447 (if (posn-area posn) 448 (if (posn-string posn)
448 ;; mode-line or header-line event 449 ;; mode-line, header-line, or display string event.
449 (button-activate (car (posn-string posn)) t) 450 (button-activate (posn-string posn) t)
450 (push-button (posn-point posn)) t))) 451 (push-button (posn-point posn)) t)))
451 ;; POS is just normal position 452 ;; POS is just normal position
452 (let ((button (button-at (or pos (point))))) 453 (let ((button (button-at (or pos (point)))))
diff --git a/lisp/hilit-chg.el b/lisp/hilit-chg.el
index 7b5e2b54300..8660f876bfa 100644
--- a/lisp/hilit-chg.el
+++ b/lisp/hilit-chg.el
@@ -523,28 +523,12 @@ the text properties of type `hilit-chg'."
523 (remove-overlays beg end 'hilit-chg t) 523 (remove-overlays beg end 'hilit-chg t)
524 (hilit-chg-display-changes beg end)) 524 (hilit-chg-display-changes beg end))
525 525
526;; Inspired by font-lock. Something like this should be moved to subr.el.
527(defmacro highlight-save-buffer-state (&rest body)
528 "Bind variables according to VARLIST and eval BODY restoring buffer state."
529 (declare (indent 0) (debug t))
530 (let ((modified (make-symbol "modified")))
531 `(let* ((,modified (buffer-modified-p))
532 (inhibit-modification-hooks t)
533 deactivate-mark
534 ;; So we don't check the file's mtime.
535 buffer-file-name
536 buffer-file-truename)
537 (progn
538 ,@body)
539 (unless ,modified
540 (restore-buffer-modified-p nil)))))
541
542;;;###autoload 526;;;###autoload
543(defun highlight-changes-remove-highlight (beg end) 527(defun highlight-changes-remove-highlight (beg end)
544 "Remove the change face from the region between BEG and END. 528 "Remove the change face from the region between BEG and END.
545This allows you to manually remove highlighting from uninteresting changes." 529This allows you to manually remove highlighting from uninteresting changes."
546 (interactive "r") 530 (interactive "r")
547 (highlight-save-buffer-state 531 (with-silent-modifications
548 (remove-text-properties beg end '(hilit-chg nil)) 532 (remove-text-properties beg end '(hilit-chg nil))
549 (hilit-chg-fixup beg end))) 533 (hilit-chg-fixup beg end)))
550 534
@@ -568,40 +552,40 @@ This allows you to manually remove highlighting from uninteresting changes."
568 (if (and highlight-changes-mode 552 (if (and highlight-changes-mode
569 highlight-changes-visible-mode) 553 highlight-changes-visible-mode)
570 (hilit-chg-fixup beg end)) 554 (hilit-chg-fixup beg end))
571 (highlight-save-buffer-state 555 (with-silent-modifications
572 (if (and (= beg end) (> leng-before 0)) 556 (if (and (= beg end) (> leng-before 0))
573 ;; deletion 557 ;; deletion
574 (progn 558 (progn
575 ;; The eolp and bolp tests are a kludge! But they prevent 559 ;; The eolp and bolp tests are a kludge! But they prevent
576 ;; rather nasty looking displays when deleting text at the end 560 ;; rather nasty looking displays when deleting text at the end
577 ;; of line, such as normal corrections as one is typing and 561 ;; of line, such as normal corrections as one is typing and
578 ;; immediately makes a correction, and when deleting first 562 ;; immediately makes a correction, and when deleting first
579 ;; character of a line. 563 ;; character of a line.
580 ;; (if (= leng-before 1) 564 ;; (if (= leng-before 1)
581 ;; (if (eolp) 565 ;; (if (eolp)
582 ;; (setq beg-decr 0 end-incr 0) 566 ;; (setq beg-decr 0 end-incr 0)
583 ;; (if (bolp) 567 ;; (if (bolp)
584 ;; (setq beg-decr 0)))) 568 ;; (setq beg-decr 0))))
585 ;; (setq beg (max (- beg beg-decr) (point-min))) 569 ;; (setq beg (max (- beg beg-decr) (point-min)))
586 (setq end (min (+ end end-incr) (point-max))) 570 (setq end (min (+ end end-incr) (point-max)))
587 (setq type 'hilit-chg-delete)) 571 (setq type 'hilit-chg-delete))
588 ;; Not a deletion. 572 ;; Not a deletion.
589 ;; Most of the time the following is not necessary, but 573 ;; Most of the time the following is not necessary, but
590 ;; if the current text was marked as a deletion then 574 ;; if the current text was marked as a deletion then
591 ;; the old overlay is still in effect. So if the user adds some 575 ;; the old overlay is still in effect. So if the user adds some
592 ;; text where she earlier deleted text, we have to remove the 576 ;; text where she earlier deleted text, we have to remove the
593 ;; deletion marking, and replace it explicitly with a `changed' 577 ;; deletion marking, and replace it explicitly with a `changed'
594 ;; marking, otherwise its highlighting would disappear. 578 ;; marking, otherwise its highlighting would disappear.
595 (if (eq (get-text-property end 'hilit-chg) 'hilit-chg-delete) 579 (if (eq (get-text-property end 'hilit-chg) 'hilit-chg-delete)
596 (save-restriction 580 (save-restriction
597 (widen) 581 (widen)
598 (put-text-property end (+ end 1) 'hilit-chg 'hilit-chg) 582 (put-text-property end (+ end 1) 'hilit-chg 'hilit-chg)
599 (if highlight-changes-visible-mode 583 (if highlight-changes-visible-mode
600 (hilit-chg-fixup beg (+ end 1)))))) 584 (hilit-chg-fixup end (+ end 1))))))
601 (unless no-property-change 585 (unless no-property-change
602 (put-text-property beg end 'hilit-chg type)) 586 (put-text-property beg end 'hilit-chg type))
603 (if (or highlight-changes-visible-mode no-property-change) 587 (if (or highlight-changes-visible-mode no-property-change)
604 (hilit-chg-make-ov type beg end))))))) 588 (hilit-chg-make-ov type beg end)))))))
605 589
606(defun hilit-chg-update () 590(defun hilit-chg-update ()
607 "Update a buffer's highlight changes when visibility changed." 591 "Update a buffer's highlight changes when visibility changed."
@@ -635,7 +619,7 @@ This removes all saved change information."
635 (message "Cannot remove highlighting from read-only mode buffer %s" 619 (message "Cannot remove highlighting from read-only mode buffer %s"
636 (buffer-name)) 620 (buffer-name))
637 (remove-hook 'after-change-functions 'hilit-chg-set-face-on-change t) 621 (remove-hook 'after-change-functions 'hilit-chg-set-face-on-change t)
638 (highlight-save-buffer-state 622 (with-silent-modifications
639 (hilit-chg-hide-changes) 623 (hilit-chg-hide-changes)
640 (hilit-chg-map-changes 624 (hilit-chg-map-changes
641 (lambda (_prop start stop) 625 (lambda (_prop start stop)
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 1d9d098e71c..68a47d91023 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -156,11 +156,6 @@ Prompts for bug subject. Leaves you in a mail buffer."
156 (when (string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version) 156 (when (string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
157 (setq topic (concat (match-string 1 emacs-version) "; " topic)))) 157 (setq topic (concat (match-string 1 emacs-version) "; " topic))))
158 (let ((from-buffer (current-buffer)) 158 (let ((from-buffer (current-buffer))
159 ;; Put these properties on semantically-void text.
160 ;; report-emacs-bug-hook deletes these regions before sending.
161 (prompt-properties '(field emacsbug-prompt
162 intangible but-helpful
163 rear-nonsticky t))
164 (can-insert-mail (or (report-emacs-bug-can-use-xdg-email) 159 (can-insert-mail (or (report-emacs-bug-can-use-xdg-email)
165 (report-emacs-bug-can-use-osx-open))) 160 (report-emacs-bug-can-use-osx-open)))
166 user-point message-end-point) 161 user-point message-end-point)
@@ -190,7 +185,7 @@ Prompts for bug subject. Leaves you in a mail buffer."
190 (insert (format "The report will be sent to %s.\n\n" 185 (insert (format "The report will be sent to %s.\n\n"
191 report-emacs-bug-address)) 186 report-emacs-bug-address))
192 (insert "This bug report will be sent to the ") 187 (insert "This bug report will be sent to the ")
193 (insert-button 188 (insert-text-button
194 "Bug-GNU-Emacs" 189 "Bug-GNU-Emacs"
195 'face 'link 190 'face 'link
196 'help-echo (concat "mouse-2, RET: Follow this link") 191 'help-echo (concat "mouse-2, RET: Follow this link")
@@ -198,7 +193,7 @@ Prompts for bug subject. Leaves you in a mail buffer."
198 (browse-url "http://lists.gnu.org/archive/html/bug-gnu-emacs/")) 193 (browse-url "http://lists.gnu.org/archive/html/bug-gnu-emacs/"))
199 'follow-link t) 194 'follow-link t)
200 (insert " mailing list\nand the GNU bug tracker at ") 195 (insert " mailing list\nand the GNU bug tracker at ")
201 (insert-button 196 (insert-text-button
202 "debbugs.gnu.org" 197 "debbugs.gnu.org"
203 'face 'link 198 'face 'link
204 'help-echo (concat "mouse-2, RET: Follow this link") 199 'help-echo (concat "mouse-2, RET: Follow this link")
@@ -216,11 +211,10 @@ usually do not have translators for other languages.\n\n")))
216 (insert "Please describe exactly what actions triggered the bug, and\n" 211 (insert "Please describe exactly what actions triggered the bug, and\n"
217 "the precise symptoms of the bug. If you can, give a recipe\n" 212 "the precise symptoms of the bug. If you can, give a recipe\n"
218 "starting from `emacs -Q':\n\n") 213 "starting from `emacs -Q':\n\n")
219 (add-text-properties (save-excursion 214 (let ((txt (delete-and-extract-region
220 (rfc822-goto-eoh) 215 (save-excursion (rfc822-goto-eoh) (line-beginning-position 2))
221 (line-beginning-position 2)) 216 (point))))
222 (point) 217 (insert (propertize "\n" 'display txt)))
223 prompt-properties)
224 (setq user-point (point)) 218 (setq user-point (point))
225 (insert "\n\n") 219 (insert "\n\n")
226 220
@@ -232,7 +226,8 @@ usually do not have translators for other languages.\n\n")))
232 (if (file-readable-p debug-file) 226 (if (file-readable-p debug-file)
233 (insert "For information about debugging Emacs, please read the file\n" 227 (insert "For information about debugging Emacs, please read the file\n"
234 debug-file ".\n"))) 228 debug-file ".\n")))
235 (add-text-properties (1+ user-point) (point) prompt-properties) 229 (let ((txt (delete-and-extract-region (1+ user-point) (point))))
230 (insert (propertize "\n" 'display txt)))
236 231
237 (insert "\n\nIn " (emacs-version) "\n") 232 (insert "\n\nIn " (emacs-version) "\n")
238 (if (stringp emacs-bzr-version) 233 (if (stringp emacs-bzr-version)
@@ -430,14 +425,7 @@ and send the mail again%s."
430 from)) 425 from))
431 (not (yes-or-no-p 426 (not (yes-or-no-p
432 (format "Is `%s' really your email address? " from))) 427 (format "Is `%s' really your email address? " from)))
433 (error "Please edit the From address and try again")))) 428 (error "Please edit the From address and try again"))))))
434 ;; Delete the uninteresting text that was just to help fill out the report.
435 (rfc822-goto-eoh)
436 (forward-line 1)
437 (let ((pos (1- (point))))
438 (while (setq pos (text-property-any pos (point-max)
439 'field 'emacsbug-prompt))
440 (delete-region pos (field-end (1+ pos)))))))
441 429
442 430
443(provide 'emacsbug) 431(provide 'emacsbug)