From: Lars Ingebrigtsen Date: Sat, 14 Apr 2018 20:38:53 +0000 (+0200) Subject: Further shr line folding/link continuation tweaks X-Git-Tag: emacs-27.0.90~5209 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=196dc887d8ba324df01d594d5eda61591e251ff0;p=emacs.git Further shr line folding/link continuation tweaks * lisp/net/shr.el (shr-fill-line): Tweak the link continuations further when folding lines. --- diff --git a/lisp/net/shr.el b/lisp/net/shr.el index d12ee684937..5eb35b74dd1 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -734,18 +734,25 @@ size, and full-buffer size." (skip-chars-forward " ") (search-forward " " (line-end-position) 'move))) ;; Success; continue. - (let ((props (copy-sequence (text-properties-at (point)))) - (gap-start (point))) - (when (= (preceding-char) ?\s) - (delete-char -1)) - ;; We don't want to use the faces on the indentation, because - ;; that's ugly, but we want all the other properties to be - ;; continuous so that links do not split up into many links - ;; (which makes navigation awkward). - (setq props (plist-put props 'face nil)) + (when (= (preceding-char) ?\s) + (delete-char -1)) + (let ((gap-start (point))) (insert "\n") (shr-indent) - (add-text-properties gap-start (point) props)) + (when (and (> (1- gap-start) (point-min)) + ;; The link on both sides of the newline are the + ;; same... + (equal (get-text-property (point) 'shr-url) + (get-text-property (1- gap-start) 'shr-url))) + ;; ... so we join the two bits into one link logically, but + ;; not visually. This makes navigation between links work + ;; well, but avoids underscores before the link on the next + ;; line when indented. + (let ((props (copy-sequence (text-properties-at (point))))) + ;; We don't want to use the faces on the indentation, because + ;; that's ugly. + (setq props (plist-put props 'face nil)) + (add-text-properties gap-start (point) props)))) (setq start (point)) (shr-vertical-motion shr-internal-width) (when (looking-at " $")