aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2014-12-13 16:23:40 +0100
committerLars Magne Ingebrigtsen2014-12-13 16:23:40 +0100
commit76f9994d677e0440584216e4e47be37e2d3dc312 (patch)
tree6cff28c805e5941d9d5e16115bb2aa1f7be8d20b
parent987d2f9421bc854893673c234c02479583476785 (diff)
downloademacs-76f9994d677e0440584216e4e47be37e2d3dc312.tar.gz
emacs-76f9994d677e0440584216e4e47be37e2d3dc312.zip
Make shr fold long title texts
* net/shr.el (shr-fold-text): New function. (shr-show-alt-text, shr-urlify, shr-tag-img): Use it to fold long alt/title texts.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/net/shr.el13
2 files changed, 14 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6955c3c6cca..5caf37672c7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12014-12-13 Lars Magne Ingebrigtsen <larsi@gnus.org> 12014-12-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 2
3 * net/shr.el (shr-fold-text): New function.
4 (shr-show-alt-text, shr-urlify, shr-tag-img): Use it to fold long
5 alt/title texts.
6
3 * files.el (directory-files-recursively): Really check whether 7 * files.el (directory-files-recursively): Really check whether
4 files are symlinks. 8 files are symlinks.
5 (directory-name-p): New function. 9 (directory-name-p): New function.
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 695b91dcb1b..2fff3603546 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -301,7 +301,7 @@ redirects somewhere else."
301 (let ((text (get-text-property (point) 'shr-alt))) 301 (let ((text (get-text-property (point) 'shr-alt)))
302 (if (not text) 302 (if (not text)
303 (message "No image under point") 303 (message "No image under point")
304 (message "%s" text)))) 304 (message "%s" (shr-fold-text text)))))
305 305
306(defun shr-browse-image (&optional copy-url) 306(defun shr-browse-image (&optional copy-url)
307 "Browse the image under point. 307 "Browse the image under point.
@@ -412,6 +412,13 @@ size, and full-buffer size."
412 (cdr (assq 'color shr-stylesheet)) 412 (cdr (assq 'color shr-stylesheet))
413 (cdr (assq 'background-color shr-stylesheet)))))))) 413 (cdr (assq 'background-color shr-stylesheet))))))))
414 414
415(defun shr-fold-text (text)
416 (with-temp-buffer
417 (let ((shr-indentation 0)
418 (shr-internal-width (window-width)))
419 (shr-insert text)
420 (buffer-string))))
421
415(define-inline shr-char-breakable-p (char) 422(define-inline shr-char-breakable-p (char)
416 "Return non-nil if a line can be broken before and after CHAR." 423 "Return non-nil if a line can be broken before and after CHAR."
417 (inline-quote (aref fill-find-break-point-function-table ,char))) 424 (inline-quote (aref fill-find-break-point-function-table ,char)))
@@ -881,7 +888,7 @@ START, and END. Note that START and END should be markers."
881 (add-text-properties 888 (add-text-properties
882 start (point) 889 start (point)
883 (list 'shr-url url 890 (list 'shr-url url
884 'help-echo (if title (format "%s (%s)" url title) url) 891 'help-echo (if title (shr-fold-text (format "%s (%s)" url title)) url)
885 'follow-link t 892 'follow-link t
886 'mouse-face 'highlight 893 'mouse-face 'highlight
887 'keymap shr-map))) 894 'keymap shr-map)))
@@ -1283,7 +1290,7 @@ The preference is a float determined from `shr-prefer-media-type'."
1283 (put-text-property start (point) 'image-displayer 1290 (put-text-property start (point) 'image-displayer
1284 (shr-image-displayer shr-content-function)) 1291 (shr-image-displayer shr-content-function))
1285 (put-text-property start (point) 'help-echo 1292 (put-text-property start (point) 'help-echo
1286 (or (dom-attr dom 'title) alt))) 1293 (shr-fold-text (or (dom-attr dom 'title) alt))))
1287 (setq shr-state 'image))))) 1294 (setq shr-state 'image)))))
1288 1295
1289(defun shr-tag-pre (dom) 1296(defun shr-tag-pre (dom)