Commit graph

389 commits

Author SHA1 Message Date
Andreas Schwab
edb1d491d9 * lisp/net/shr.el (shr-expand-url): Also strip trailing
whitespace.
2021-12-23 19:07:49 +01:00
Lars Ingebrigtsen
7904cae492 Rework how shr sets <span id='foo'> targets to make it more reliable
* lisp/net/eww.el (eww-display-html): The target is now a list.
* lisp/net/shr.el (shr--link-targets): New variable.
(shr-insert-document): Set the targets.
(shr-descend): Save targets and apply them later.
(shr-ensure-paragraph): Remove hack to avoid filling from removing
targets.
(shr-tag-a): Save targets for later.
(shr-render-td-1): Bind and set targets (bug#52512).
2021-12-19 13:44:21 +01:00
LdBeth
276fd48176 Add a shr-allowed-images user option
* lisp/net/shr.el (shr-allowed-images): New variable (bug#52594).
(shr-image-is-blocked): New function to use it.
(shr-tag-img): Use it.
* doc/misc/eww.texi (Advanced): Document it.

Copyright-paperwork-exempt: yes
2021-12-19 12:26:15 +01:00
Stefan Kangas
b331819302 Merge from origin/emacs-28
5708da48d1 Revert "Make `M-x run-python' select the window again"
aa2872a127 Make `M-x run-python' select the window again
c8e19b3a84 Don't bug out on certain empty elements with ids
2021-12-11 06:56:31 +01:00
Lars Ingebrigtsen
c8e19b3a84 Don't bug out on certain empty elements with ids
* lisp/net/shr.el (shr-descend): Fix empty-element #id targetting
(bug#52391).
2021-12-10 12:47:10 +01:00
Lars Ingebrigtsen
5a9965f0c7 Fix previous shr-parse-style change
* lisp/net/shr.el (shr-parse-style): Fix previous clean-up here
(which wasn't well thought through).
2021-12-06 21:43:43 +01:00
Lars Ingebrigtsen
77de40aed3 Audit `string-match' usage in shr.el
* lisp/net/shr.el (shr-descend):
(shr-insert):
(shr-expand-url):
(shr-image-from-data):
(shr-dom-print):
(shr-parse-style):
(shr-tag-object):
(shr-tag-img):
(shr-render-td-1): Prefer string-match-p and string-search over
string-match where possible.
2021-12-06 01:16:23 +01:00
Lars Ingebrigtsen
93824a760e Add new face `variable-pitch-text'
* doc/emacs/display.texi (Standard Faces): Mention in.

* lisp/faces.el (variable-pitch-text): New face.

* lisp/gnus/gnus-art.el (gnus-header): Use it.

* lisp/net/shr.el (shr-text): Use it.
2021-12-01 17:20:16 +01:00
Lars Ingebrigtsen
a2d98c54f7 Use pixel-fill-width in shr.el
* lisp/net/shr.el (shr--window-width): Factor out into own function.
(shr-insert-document): Use it.
(shr-fill-text): Ditto.
2021-11-30 16:54:34 +01:00
Lars Ingebrigtsen
72b7fccc15 Add new package pixel-fill.el
* lisp/net/shr.el (shr-char-breakable-p, shr-char-nospace-p)
(shr-char-kinsoku-bol-p, shr-char-kinsoku-eol-p)
(shr-find-fill-point): Moved to pixel-fill.el and renamed.
(shr-pixel-region): Made obsolete.
(shr-fill-line): Use pixel-fill-region.

* lisp/textmodes/pixel-fill.el: New package.
2021-11-30 02:07:22 +01:00
Lars Ingebrigtsen
7fea9c8415 Define a face for shr text
* lisp/net/shr.el (shr-text): New face.
(shr-insert): Use it instead of hard-coding `variable-pitch'.
2021-11-25 11:17:00 +01:00
Lars Ingebrigtsen
4351722477 Make shr render text with superscripts prettier
* lisp/net/shr.el (shr-sup): New face.
(shr-tag-sup, shr-tag-sub): Use it to make the super/subscripts
slightly smaller so that we don't get uneven line heights with
text that uses these.
2021-11-20 11:42:44 +01:00
Mattias Engdegård
09a5dd8628 String backslash corrections
* lisp/net/shr.el (shr-tag-video): Remove ineffective backslash.
* test/lisp/emacs-lisp/package-tests.el
(package-test-macro-compilation-gz): Make dot literal as intended.
2021-11-18 20:54:32 +01:00
Lars Ingebrigtsen
2daffe3550 Adjust defvar-keymap' and define-keymap' to the new syntax
* lisp/vc/smerge-mode.el (smerge-basic-map):
* lisp/vc/pcvs.el (cvs-mode-map):
(cvs-minor-mode-prefix):
* lisp/vc/log-view.el (log-view-mode-map):
* lisp/vc/log-edit.el (log-edit-mode-map):
* lisp/vc/diff-mode.el (diff-mode-shared-map):
(diff-minor-mode-prefix):
* lisp/vc/cvs-status.el (cvs-status-mode-map):
* lisp/simple.el (special-mode-map):
* lisp/outline.el (outline--insert-open-button):
(outline--insert-close-button):
* lisp/net/shr.el (shr-map):
* lisp/net/eww.el (eww-link-keymap):
(eww-mode-map):
(eww-submit-map):
(eww-bookmark-mode-map):
(eww-history-mode-map):
(eww-buffers-mode-map):
* lisp/mh-e/mh-speed.el (:keymap):
* lisp/mh-e/mh-show.el (:keymap):
* lisp/mh-e/mh-search.el (:keymap):
* lisp/mh-e/mh-letter.el (:keymap):
* lisp/mh-e/mh-folder.el (:keymap):
* lisp/international/emoji.el (emoji-list-mode-map):
* lisp/gnus/spam.el (:keymap):
* lisp/gnus/mml.el (mml-mode-map):
* lisp/gnus/message.el (message-mode-map):
* lisp/gnus/gnus-undo.el (gnus-undo-mode-map):
* lisp/gnus/gnus-topic.el (gnus-topic-mode-map):
* lisp/gnus/gnus-sum.el (:keymap):
* lisp/gnus/gnus-srvr.el (gnus-server-mode-map):
(gnus-browse-mode-map):
* lisp/gnus/gnus-salt.el (gnus-pick-mode-map):
(gnus-tree-mode-map):
* lisp/gnus/gnus-msg.el (:prefix):
* lisp/gnus/gnus-ml.el (gnus-mailing-list-mode-map):
* lisp/gnus/gnus-kill.el (gnus-kill-file-mode-map):
* lisp/gnus/gnus-html.el (gnus-html-displayed-image-map):
* lisp/gnus/gnus-group.el (:keymap):
* lisp/gnus/gnus-eform.el (gnus-edit-form-mode-map):
* lisp/gnus/gnus-draft.el (gnus-draft-mode-map):
* lisp/gnus/gnus-dired.el (gnus-dired-mode-map):
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-mode-map):
* lisp/gnus/gnus-art.el (:keymap):
(gnus-article-edit-mode-map):
* lisp/gnus/gnus-agent.el (gnus-agent-group-mode-map):
(gnus-agent-summary-mode-map):
(gnus-agent-server-mode-map):
(gnus-category-mode-map): Adjust `defvar-keymap' and
`define-keymap' to the new syntax.
2021-11-16 08:26:24 +01:00
Lars Ingebrigtsen
71bf21f58b Fix image-animate declaration
* lisp/net/shr.el (image-animate): Fix declaration.
2021-11-12 03:31:53 +01:00
Lars Ingebrigtsen
a204b29d5b Allow stopping animations automatically when the image disappears
* lisp/image.el (image-animate): Allow the animation to be stopped
automatically when the image is removed from the buffer.
(image-animate-timeout): Stop the animation if the image is
removed (and that has been requested).

* lisp/net/shr.el (shr-put-image): Stop animations if the image is
removed.
2021-11-12 03:31:53 +01:00
Lars Ingebrigtsen
18ebe6c4da Fix the look of the <video> elements in shr
* lisp/net/shr.el (shr-tag-video): Tweak the look of the video element.
2021-11-10 02:31:54 +01:00
Po Lu
2ccaa95355 Fix compiler warning building net/shr.el without xwidget support
* lisp/net/shr.el (xwidget-webkit-execute-script): New function
declaration (bug#51705).
2021-11-09 08:27:23 +01:00
Lars Ingebrigtsen
430d12e3c0 Don't create temporary files for <video>
* lisp/net/shr.el (shr-tag-audio): Don't create a temporary file;
just update the DOM directly.
2021-11-09 07:47:17 +01:00
Lars Ingebrigtsen
3e2c024c41 Fix typo in last shr change
* lisp/net/shr.el (shr-tag-video): Require xwidgets, because it's
used from callbacks.
2021-11-09 06:44:58 +01:00
Lars Ingebrigtsen
0a2439fa31 Fix shr-tag-video startup issue
* lisp/net/shr.el (shr-tag-video): Require xwidgets, because it's
used from callbacks.
2021-11-09 06:26:57 +01:00
Lars Ingebrigtsen
9a67efa11b Optionally use use xwidgets to display <video> elements in shr
* doc/misc/eww.texi (Advanced): Document it.
* lisp/net/shr.el (shr-use-xwidgets-for-media): New user option.
(shr-tag-video): Use xwidgets to display <video> elements.
2021-11-09 06:19:09 +01:00
Eli Zaretskii
0abf01402b Merge from origin/emacs-28
f1c9286 ; * doc/misc/org.org: fix capture context example
af67ce6 Merge branch 'emacs-28' of git.savannah.gnu.org:/srv/git/emac...
610680a Fix rendering of title-less <abbr> tags in shr
2ba4ccf ; * lisp/files.el (make-nearby-temp-file): Doc fix.
2021-10-31 18:46:29 +02:00
Lars Ingebrigtsen
610680a8d3 Fix rendering of title-less <abbr> tags in shr
* lisp/net/shr.el (shr-tag-abbr): Render <abbr> tags that have no
title (bug#51525).
2021-10-31 16:20:18 +01:00
Lars Ingebrigtsen
4103123806 Change the call convention for `defvar-keymap'
* doc/lispref/keymaps.texi (Changing Key Bindings): Adjust
documentation.

* lisp/simple.el (special-mode-map):
* lisp/net/shr.el (shr-map):
* lisp/net/eww.el (eww-link-keymap):
(eww-mode-map):
(eww-submit-map):
(eww-textarea-map):
(eww-bookmark-mode-map):
(eww-history-mode-map):
(eww-buffers-mode-map):
* lisp/gnus/message.el (message-mode-map):
* lisp/gnus/gnus-html.el (gnus-html-image-map):
* lisp/gnus/gnus-eform.el (gnus-edit-form-mode-map):
* lisp/gnus/gnus-dired.el (gnus-dired-mode-map):
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-mode-map):
Adjust usage of `defvar-keymap'.

* lisp/subr.el (define-keymap, define-keymap--define): Change how
these functions call each other.
(defvar-keymap): Change interface to be more like `define-keymap'.

* lisp/emacs-lisp/lisp-mode.el (lisp-indent--defvar-keymap): Remove.
(lisp-indent-function): Don't use it.
2021-10-05 10:34:37 +02:00
Lars Ingebrigtsen
859190f03e Convert some keymaps to defvar-keymap
* lisp/simple.el (special-mode-map):
* lisp/net/shr.el (shr-map):
* lisp/net/eww.el (eww-link-keymap):
(eww-mode-map):
(eww-submit-map):
(eww-bookmark-mode-map):
(eww-history-mode-map):
(eww-buffers-mode-map):
* lisp/gnus/message.el (message-mode-map): Use defvar-keymap.

* lisp/gnus/gnus-eform.el (gnus-edit-form-mode-map):
* lisp/gnus/gnus-dired.el (gnus-dired-mode-map):
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-mode-map): Use
defvar-keymap.

* lisp/gnus/gnus-group.el (gnus-group-mode-map): Use define-keymap.

* lisp/gnus/gnus-html.el (gnus-html-image-map): Use defvar-keymap.

* lisp/gnus/gnus.el: Autoload gnus-score-edit-all-score.
2021-10-04 10:15:11 +02:00
Stefan Kangas
63f419f133 ; Minor stylistic fixes found by checkdoc 2021-09-16 19:37:07 +02:00
Protesilaos Stavrou
1431fd91b4 Add faces for shr heading elements (bug#49433)
* etc/NEWS: Document new faces.
* lisp/net/shr.el (shr-h1, shr-h2, shr-h3, shr-h4, shr-h5, shr-h6):
Define new faces.
(shr-tag-h1): Remove inclusion of 'variable-pitch' face.  Fix
bug#49433 by applying a new face directly.
(shr-tag-h2, shr-tag-h3, shr-tag-h4, shr-tag-h5, shr-tag-h6): Apply
new faces.
2021-07-06 17:06:17 +02:00
Stefan Monnier
26041ec8d5 * lisp/net/shr.el (shr-image-displayer): Use proper closures 2021-05-18 19:15:04 -04:00
Ralph Schleicher
9dc28e1fca Add command in eww to toggle images
* lisp/net/eww.el (eww-toggle-images): New function.
(eww-mode-map): Add key binding and menu entry.
* lisp/net/shr.el (shr-inhibit-images): Make it customizable.
* doc/misc/eww.texi (Basics): Document eww-toggle-images.
Fix index entries for shr-use-fonts and shr-use-colors.
(Advanced): Document shr-inhibit-images
(bug#47705).
2021-04-12 10:31:46 +02:00
Eli Zaretskii
0f494760d3 ; * lisp/net/shr.el (shr-insert-document): Fix last change. 2021-04-11 09:35:09 +03:00
Stefan Monnier
d55d07af70 * lisp/net/shr.el (shr-insert-document): Explain why bidi-display-reordering 2021-04-10 20:06:35 -04:00
Stefan Monnier
dc083ebc4e * lisp/net/*.el: Use lexical-binding
Also remove some redundant `:group` arguments.

* lisp/net/eudc-export.el: Use lexical-binding.
(eudc-create-bbdb-record): Use `cl-progv` and `apply` to avoid `eval`.

* lisp/net/eudc-hotlist.el: Use lexical-binding.

* lisp/net/eudc.el (eudc-print-attribute-value): Use `funcall` to avoid
`eval`.

* lisp/net/eudcb-bbdb.el: Use lexical-binding.
(eudc-bbdb-filter-non-matching-record): Use `funcall` to avoid `eval`.
Move `bbdb-val` binding to avoid `setq`.
Use `seq-some` instead of `eval+or`.
(eudc-bbdb-format-record-as-result): Use `dolist` and `pcase`.
Use `funcall` to avoid `eval`.
(eudc-bbdb-query-internal): Simplify a bit.

* lisp/net/eudcb-ldap.el: Use lexical-binding.
(eudc-ldap-get-host-parameter): Use `defalias` to avoid `eval-and-compile`.

* lisp/net/telnet.el: Use lexical-binding.
* lisp/net/quickurl.el: Use lexical-binding.
* lisp/net/newst-ticker.el: Use lexical-binding.
* lisp/net/newst-reader.el: Use lexical-binding.
* lisp/net/goto-addr.el: Use lexical-binding.
* lisp/net/gnutls.el: Use lexical-binding.
* lisp/net/eudcb-macos-contacts.el: Use lexical-binding.
* lisp/net/eudcb-mab.el: Use lexical-binding.

* lisp/net/net-utils.el: Use lexical-binding.
(finger): Remove unused var `found`.

* lisp/net/network-stream.el (open-protocol-stream): Remove redundant
`defalias`.

* lisp/net/newst-plainview.el: Use lexical-binding.
(newsticker-hide-entry, newsticker-show-entry): Remove unused var
`is-invisible`.
(w3m-fill-column, w3-maximum-line-length): Declare vars.

* lisp/net/tramp.el (tramp-compute-multi-hops):
* lisp/net/tramp-compat.el (tramp-compat-temporary-file-directory):
* lisp/net/tramp-cmds.el (tramp-default-rename-file):
* lisp/net/webjump.el (webjump): Don't forget lexical-binding for `eval`.
2021-03-08 10:11:22 -05:00
Basil L. Contovounesios
cccd701ac9 ; Finish recent rename of completion-* predicates. 2021-02-17 13:27:56 +00:00
Lars Ingebrigtsen
2594162b23 Make the button completion predicate be more useful
* lisp/simple.el (completion-button-p): Rework from
`completion-at-point-p'.

* lisp/net/shr.el (shr-show-alt-text): It should be possible to
complete to commands that aren't bound to a key.
2021-02-15 04:42:32 +01:00
Lars Ingebrigtsen
f02c93ae7a Add a possible completion predicate for buttons
* lisp/simple.el (completion-at-point-p): New predicate.

* lisp/net/shr.el (shr-show-alt-text): Mark up as a button.
2021-02-14 20:34:03 +01:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Łukasz Stelmach
1e11f6f59d Handle gracefully href="" in base tags in shr
* net/shr.el (shr-tag-base): shr-parse-base can't handle empty
strings gracefully.  Don't call it unless href is a non-empty
string (bug#45355).
2020-12-23 06:26:06 +01:00
Richard M Stallman
7e3a95d8fd Add way to prevent asking "increase specpdl size?"
* net/shr.el (shr-offer-extend-specpdl): New option, default t.
(shr-descend): If shr-offer-extend-specpdl is nil, don't even ask
whether to extend the specpdl, just signal error.
2020-10-15 22:32:41 -04:00
Lars Ingebrigtsen
096f5956be Speed up shr-insert slightly
* lisp/net/shr.el (shr-insert): Speed up regularising spaces --
the vast majority of the spaces are already OK, so transforming
" " to " " just takes time.
2020-09-22 16:02:42 +02:00
Lars Ingebrigtsen
69b5d54311 Fix filling problem in shr due to zero-width id tagging
* lisp/net/shr.el (shr-descend): Fix problem with filling lines
that have a zero-width ID tag at the start.
2020-09-22 16:02:42 +02:00
Lars Ingebrigtsen
163ff19cf3 Fix bug out when indenting inserted images in shr
* lisp/net/shr.el (shr-fill-line): We may not have a
shr-indentation text property here.  In that case, default to the
dynamically bound value.
2020-09-20 13:03:20 +02:00
Lars Ingebrigtsen
7222e975be Fix problem with spurious extra paragraphs in shr
* lisp/net/shr.el (shr-ensure-paragraph): Don't regard <div
id=foo></div> (empty placeholders) as occupying any space (bug#43510).
2020-09-19 19:11:09 +02:00
Lars Ingebrigtsen
9d10a8ca05 Tweak background colours in shr when there's indentation
* lisp/net/shr.el (shr-fill-line): Get the background colour right
for the indentation, too.
2020-08-30 17:03:11 +02:00
Lars Ingebrigtsen
1064b2f65e Extend background colours in shr
* lisp/net/shr.el (shr-colorize-region): Extend backgrounds to the
end (bug#43031).  This avoid ragged edges to the right when, for
instance, the <body> has a bgcolor.
(shr-face-background): Ditto.
2020-08-25 13:57:00 +02:00
Alan Third
8f42b94fe4 Set basic SVG attributes (bug#40845)
* test/manual/image-transforms-tests.el: Replace hard-coded colors
with defaults.
* src/dispextern.h (struct image):
* src/image.c (search_image_cache):
(xbm_load_image):
(xbm_load):
(pbm_load): Rename from frame to face where relevant.
(svg_load_image): Parse the image to find out the size, then wrap it
in another SVG to set a new size and colors, etc.
(lookup_image): Use the face colors instead of the frame colors.
(search_image_cache): Add ability to ignore the face colors.
(uncache_image): Uncache all copies of the image that share the spec,
even if the face colors don't match.
* etc/NEWS: Describe the changes.
2020-08-23 16:28:17 +01:00
Eli Zaretskii
58c7dc69db Fix documentation of a recent change in shr.el
* lisp/net/shr.el (shr-max-width, shr-width): Fix typo and wording
of the doc strings.

* etc/NEWS: Fix the wording of the 'shr-max-width's entry, and
move it to the SHR section.
2020-07-18 17:40:44 +03:00
Lars Ingebrigtsen
02bad11288 Add support for a shr-max-width variable
* doc/misc/eww.texi (Advanced): Document it.

* lisp/net/shr.el (shr-max-width): Add new variable (bug#40909).
(shr-insert-document): Use it.
2020-07-17 15:45:04 +02:00
Lars Ingebrigtsen
c7b112b13f Clarify shr width computation
* lisp/net/shr.el (shr-insert-document): Clarify width
computation: shr-width was checked again in the `else' part where
we already knew it was nil.
2020-07-17 15:30:29 +02:00
Basil L. Contovounesios
bcb58180c7 ; Simplify last change in shr.el
* lisp/net/shr.el (shr-max-columns): Simplify some function calls.
2020-07-17 12:04:09 +01:00