1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-12 09:28:24 +00:00
emacs/lisp/gnus/mm-url.el

460 lines
13 KiB
EmacsLisp
Raw Normal View History

* lisp/gnus: Use lexical-binding in all the files * lisp/gnus/gnus-group.el (features): Use `dlet`. (gnus-tmp-level, gnus-tmp-marked, gnus-tmp-group): Declare vars. (gnus-group-insert-group-line): Bind dynbound vars via `let` rather than as formal args. Bind `number` as dynbound. (gnus-visual, gnus-score-find-score-files-function) (gnus-home-score-file, gnus-apply-kill-hook) (gnus-summary-expunge-below): Declare vars. (gnus-group-restart, gnus-group-list-plus): Fix `interactive` spec since the arg is unused. * lisp/gnus/mail-source.el (mail-source-bind, mail-source-bind-common): Use `dlet` and suppress the warnings about the non-prefixed dynbound vars. (mail-source-set-1): Remove unused var `auth-info`. (mail-source-call-script): Remove unused var `background`. (mail-source-fetch-pop, mail-source-check-pop): Bind pop3 vars with `dlet`. * lisp/gnus/gnus-int.el (mail-source-plugged, gnus-inhibit-demon): Declare vars. (gnus-server-opened, gnus-status-message) (gnus-open-server, gnus-close-server, gnus-request-list) (gnus-finish-retrieve-group-infos, gnus-retrieve-group-data-early) (gnus-request-list-newsgroups, gnus-request-newgroups) (gnus-request-regenerate, gnus-request-compact, gnus-request-group) (gnus-retrieve-groups, gnus-request-post, gnus-request-expunge-group) (gnus-request-scan, gnus-request-update-info, gnus-request-marks) (gnus-request-accept-article, gnus-request-create-group) (gnus-asynchronous-p, gnus-remove-denial): Bind `gnus-command-method` via `let` rather than as formal args. * lisp/gnus/gnus-topic.el (gnus-topic-insert-topic-line): Pass documented vars to eval for `gnus-topic-line-format-spec`. * lisp/gnus/message.el (message-yank-original): Use `cl-progv` rather than `eval` to bind the vars from `message-cite-style`. * lisp/gnus/mml.el (mml-parse-1): Use `apply` instead of `eval`. (gnus-newsgroup-name, gnus-displaying-mime, gnus-newsgroup-name) (gnus-article-prepare-hook, gnus-newsgroup-charset) (gnus-original-article-buffer, gnus-message-buffer) (message-this-is-news, message-this-is-mail): Declare vars. * lisp/gnus/deuglify.el (gnus-outlook-rearrange-article): Remove unused var `cite-marks`. * lisp/gnus/gnus-art.el (ansi-color-context-region): Declare var. (gnus-mime-display-attachment-buttons-in-header): Move declaration before first use. (gnus-mime-display-alternative): Remove unused var `from`. * lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-list): Remove unused var `start` `end`. * lisp/gnus/gnus-cache.el (gnus-article-decode-hook) (nnml-generate-active-function): Declare var. * lisp/gnus/gnus-cite.el (gnus-message-citation-mode): Remove unused var `keywords`. * lisp/gnus/gnus-cloud.el (gnus-cloud-encode-data): Remove unused var `cipher`. (gnus-cloud-ensure-cloud-group): Remove unused var `method`. * lisp/gnus/gnus-delay.el (gnus-delay-article): Remove unused var `days`. * lisp/gnus/gnus-html.el (gnus-html-wash-images): Remove unused vars `tag`, `string`, and `images`. (gnus-html-wash-tags): Remove unused vars `string` and `images`. * lisp/gnus/gnus-msg.el (gnus-msg-mail): Remove unused var `group-name`. (gnus-group-mail, gnus-group-news, gnus-summary-mail-other-window) (gnus-summary-news-other-window): Remove unused vars `group` and `buffer`. (gnus-configure-posting-styles): Remove unused vars `style` and `attribute`. * lisp/gnus/gnus-picon.el (gnus-picon-find-face): Remove unused vars `database`, `directory`, and `instance`. (gnus-picon-transform-newsgroups): Remove unused var `point`. * lisp/gnus/gnus-range.el (gnus-range-difference): Remove unused var `safe`. * lisp/gnus/gnus-score.el (gnus-score-load-file): Remove unused var `score-fn`. * lisp/gnus/gnus-sum.el (message-options-set-recipient): Declare var. * lisp/gnus/gnus-undo.el (gnus-undo): Fix docstring lie. * lisp/gnus/gnus-util.el (print-string-length) (iswitchb-make-buflist-hook): Declare vars. (gnus-emacs-version): Remove unused var `codename`. (gnus-rename-file): Remove unused vars `old-name` and `new-name`. * lisp/gnus/gnus-uu.el (gnus-uu-yenc-article): Remove unused var `start-char`. (gnus-asynchronous): Declare var. * lisp/gnus/mm-partial.el (gnus-displaying-mime): Declare var. (mm-inline-partial): Remove unused var `buffer`. * lisp/gnus/mm-view.el (w3m-force-redisplay, w3m-safe-url-regexp) (gnus-displaying-mime, gnus-original-article-buffer) (gnus-article-prepare-hook): Declare vars. * lisp/gnus/mml-smime.el (mml-smime-epg-encrypt): Remove unused var `boundary`. (mml-smime-epg-verify): Remove unused vars `plain` and `signature-file`. * lisp/gnus/mml1991.el (pgg-text-mode): Declare var. * lisp/gnus/mml2015.el (pgg-text-mode): Declare var. (mml2015-pgg-decrypt): Remove unused var `result`. (mml2015-epg-key-image-to-string): Remove unused var `error`. (mml2015-epg-decrypt): Remove unused var `result`. (mml2015-epg-verify): Remove unused vars `plain` and `signature-file`. * lisp/gnus/nnbabyl.el (nnml-current-directory): Declare var. * lisp/gnus/nndiary.el (nndiary-files): Move declaration before first use. * lisp/gnus/nnfolder.el (nnfolder-request-accept-article): Remove unused var `buf`. * lisp/gnus/nnmail.el (nnmail-parse-active): Remove unused var `err`. * lisp/gnus/nnmairix.el (nnmairix-request-group): Remove unused var `args`. (nnmairix-request-create-group): Remove unused var `info`. (nnmairix-request-list): Remove unused var `folder`. (nnmairix-request-set-mark): Remove unused var `propto`. (nnmairix-request-set-mark): Remove unused vars `number` and `method`. (nnmairix-close-group): Remove unused var `method`. (nnmairix-create-search-group-from-message): Remove unused var `cq`. (nnmairix-create-server-and-default-group): Remove unused var `create`. (nnmairix-purge-old-groups): Remove unused var `folder`. (nnmairix-remove-tick-mark-original-article, nnmairix-get-valid-servers): Remove unused var `cur`. (nnmairix-replace-group-and-numbers): Remove unused var `header`. (nnmairix-goto-original-article): Remove unused var `rval`. (nnmairix-widget-create-query): Remove unused var `allwidgets`. * lisp/gnus/nnmbox.el (nnml-current-directory): Declare var. * lisp/gnus/nnmh.el (nnmh-toplev): Move declaration before first use. (nnmh-request-list-1): Remove unused var `rdir`. * lisp/gnus/nnml.el (nnml-generate-nov-file): Remove unused var `file`. * lisp/gnus/nnrss.el (nnrss-request-article): Remove unused var `post`. (nnrss-request-article): Remove unused var `fn`. (nnrss-check-group): Remove unused var `rdf-ns`. * lisp/gnus/nnweb.el (nnweb-request-article): Remove unused var `active`. (nnweb-google-parse-1): Remove unused var `Score`. * lisp/gnus/spam-stat.el (spam-stat-error-holder): Remove var. (spam-stat-buffer-words-with-scores): Remove unused var `word`. (spam-stat-score-buffer): Remove unused var `spam-stat-error-holder`. (spam-stat-split-fancy): Use `err` instead of `spam-stat-error-holder`. * lisp/gnus/spam-wash.el (spam-wash): Remove unused var `handle`. * lisp/gnus/spam.el (spam-copy-or-move-routine): Remove unused vars `article` and `mark`. (spam-register-routine): Remove unused var `article`. (spam-log-undo-registration): Remove unused var `found`. (spam-ifile-register-with-ifile): Remove unused var `parameters`. (spam-check-stat): Remove unused vars `category` and `return`. (spam-parse-list): Remove unused var `found`. (spam-filelist-register-routine): Remove unused var `from`.
2021-01-30 23:44:00 +00:00
;;; mm-url.el --- a wrapper of url functions/commands for Gnus -*- lexical-binding: t; -*-
2005-08-06 19:51:42 +00:00
2023-01-01 10:31:12 +00:00
;; Copyright (C) 2001-2023 Free Software Foundation, Inc.
;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
Merge from Gnus git master 2014-03-14 Katsumi Yamaoka <yamaoka@jpl.org> * gnus-sum.el (gnus-summary-toggle-header): Display header attachment buttons when toggling the header off. 2014-03-07 Daiki Ueno <ueno@gnu.org> * mml2015.el (mml2015-use): Don't check the availability of GnuPG commands here; instead, only check if epg-config.el is available. 2014-03-06 Lars Ingebrigtsen <larsi@gnus.org> * mml.el (mml-expand-html-into-multipart-related): Allow sending HTML messages with embedded images. (mml-generate-mime): Don't bug out if you don't have libxml. 2014-03-06 Lars Ingebrigtsen <larsi@gnus.org> * message.el (message-make-html-message-with-image-files): New command. 2014-03-05 Lars Ingebrigtsen <larsi@gnus.org> * mml.el (mml-insert-mime-headers): Allow `recipient-filename'. 2014-02-23 David Engster <deng@randomsample.de> * auth-source.el (auth-source-netrc-saver): Do not depend on `cl-lib' to stay compatible with older Emacsen, so replace `cl-loop' with `loop'. 2014-02-17 Katsumi Yamaoka <yamaoka@jpl.org> * gnus-art.el (gnus-article-prepare, gnus-article-prepare-display): Display header attachment buttons by gnus-article-prepare-display rather than gnus-article-prepare so as to view in mml-preview as well. 2014-02-10 Katsumi Yamaoka <yamaoka@jpl.org> * gnus-art.el (gnus-article-goto-part): Find a button in the body first. (gnus-mime-buttonize-attachments-in-header): Number hidden buttons. 2014-02-07 Katsumi Yamaoka <yamaoka@jpl.org> * gnus-art.el (gnus-mime-buttonize-attachments-in-header): Display buttons that are hidden in unselected alternative part as well. (gnus-mime-display-alternative): Redraw attachment buttons in header. * gmm-utils.el (gmm-labels): Add edebug spec. 2014-02-07 Lars Ingebrigtsen <larsi@gnus.org> * gnus-srvr.el (gnus-server-toggle-cloud-server): New command and keystroke. (gnus-server-toggle-cloud-server): Only allow clouding applicable types. 2014-02-05 Katsumi Yamaoka <yamaoka@jpl.org> * gnus.el (gnus-copy-overlay, gnus-overlays-at): New functions. * gnus-art.el (gnus-mime-display-attachment-buttons-in-header): New user option. (gnus-mime-buttonize-attachments-in-header): New function. (gnus-article-prepare): Use it. (gnus-mime-inline-part): Suppress extra newline. (gnus-mm-display-part): Save excursion; remove useless deleting and adding of buttons. (gnus-insert-mime-button): Allow insertion in the middle of a line. * gnus-sum.el (gnus-summary-wash-mime-map, gnus-summary-article-menu): Add gnus-mime-buttonize-attachments-in-header. 2014-02-05 Lars Ingebrigtsen <larsi@gnus.org> * nnimap.el (nnimap-request-articles): New command to download several articles at once. * gnus.el (gnus-variable-list): Save Cloud variables. 2014-02-01 Lars Ingebrigtsen <larsi@gnus.org> * gnus-cloud.el: New file to provide the Emacs Cloud. * gravatar.el (gravatar-retrieve-synchronously): XEmacs also has `url-retrieve-synchronously', apparently. * gnus-notifications.el (gravatar-retrieve-synchronously): Declare for XEmacs. * nnrss.el (libxml-parse-html-region): Silence compilation error. 2014-02-01 Daniel Dehennin <daniel.dehennin@baby-gnu.org> * gnus-mlspl.el (gnus-group-split-fancy): Use `gnus-parameters' in `gnus-group-split-fancy'. 2014-02-01 Lars Ingebrigtsen <larsi@gnus.org> * message.el (message-remove-header): Doc fix. (message-forward-included-headers): New variable. (message-remove-ignored-headers): Use it. 2014-01-31 Dave Abrahams <dave@boostpro.com> * gnus-sum.el (gnus-summary-open-group-with-article): New command. 2013-09-04 Rasmus Pank Roulund <emacs@pank.eu> * gnus-fun.el (gnus-x-face-omit-files): Regexp to omit matched results from random face commands. (gnus-face-directory): Like `gnus-x-face-directory` for png files and Face. (gnus-face-omit-files): Like `gnus-x-face-omit-files` for Face. (gnus--random-face-with-type): Generic function returning a face-type as a string. (gnus--insert-random-face-with-type): Generic function inserting a face in a message buffer header. (gnus-random-x-face): Rewritten to use `gnus--random-face-with-type`. (gnus-insert-random-x-face-header): Rewritten to use `gnus--insert-random-face-with-type`. (gnus-random-face): Return random (png) Face as string. (nus-insert-random-face-header): Insert random (png) Face in a message buffer. 2014-01-31 Lars Ingebrigtsen <larsi@gnus.org> * mm-url.el: Remove all usage of w3. * nnrss.el: Ditto. * mm-decode.el: Ditto. * mm-view.el: Ditto. * gnus-setup.el: Remove outdated file.
2014-03-23 23:13:36 +00:00
;; Some code is stolen from w3 and url packages. Some are moved from
;; nnweb.
;; TODO: Support POST, cookie.
;;; Code:
gnus: replace cl with cl-lib * lisp/gnus/gnus-agent.el, lisp/gnus/gnus-art.el: * lisp/gnus/gnus-async.el, lisp/gnus/gnus-cache.el: * lisp/gnus/gnus-demon.el, lisp/gnus/gnus-group.el: * lisp/gnus/gnus-icalendar.el, lisp/gnus/gnus-logic.el: * lisp/gnus/gnus-msg.el, lisp/gnus/gnus-picon.el: * lisp/gnus/gnus-registry.el, lisp/gnus/gnus-salt.el: * lisp/gnus/gnus-score.el, lisp/gnus/gnus-spec.el: * lisp/gnus/gnus-srvr.el, lisp/gnus/gnus-start.el: * lisp/gnus/gnus-sum.el, lisp/gnus/gnus-topic.el: * lisp/gnus/gnus-util.el, lisp/gnus/gnus-uu.el, lisp/gnus/gnus-win.el: * lisp/gnus/mail-source.el, lisp/gnus/mm-decode.el: * lisp/gnus/mm-encode.el, lisp/gnus/mm-url.el, lisp/gnus/mm-view.el: * lisp/gnus/mml-smime.el, lisp/gnus/mml.el, lisp/gnus/mml2015.el: * lisp/gnus/nnbabyl.el, lisp/gnus/nndoc.el, lisp/gnus/nneething.el: * lisp/gnus/nnheader.el, lisp/gnus/nnimap.el, lisp/gnus/nnmail.el: * lisp/gnus/nnmaildir.el, lisp/gnus/nnoo.el, lisp/gnus/nnrss.el: * lisp/gnus/nnspool.el, lisp/gnus/nntp.el, lisp/gnus/nnvirtual.el: * lisp/gnus/nnweb.el, lisp/gnus/spam.el: Replace cl with cl-lib. * lisp/gnus/canlock.el, lisp/gnus/gnus-bcklg.el: * lisp/gnus/gnus-cite.el, lisp/gnus/gnus-cloud.el: * lisp/gnus/gnus-draft.el, lisp/gnus/gnus-dup.el: * lisp/gnus/gnus-fun.el, lisp/gnus/gnus-html.el: * lisp/gnus/gnus-int.el, lisp/gnus/gnus-kill.el, lisp/gnus/gnus-ml.el: * lisp/gnus/gnus-mlspl.el, lisp/gnus/gnus-range.el: * lisp/gnus/gnus-undo.el, lisp/gnus/gnus-vm.el: * lisp/gnus/mm-partial.el, lisp/gnus/mm-uu.el, lisp/gnus/mml1991.el: * lisp/gnus/nnagent.el, lisp/gnus/nndiary.el, lisp/gnus/nndir.el: * lisp/gnus/nndraft.el, lisp/gnus/nnfolder.el, lisp/gnus/nngateway.el: * lisp/gnus/nnmairix.el, lisp/gnus/nnmbox.el, lisp/gnus/nnmh.el: * lisp/gnus/nnml.el, lisp/gnus/score-mode.el, lisp/gnus/smiley.el: No need for cl.
2018-03-23 20:13:09 +00:00
(eval-when-compile (require 'cl-lib))
(require 'mm-util)
(require 'gnus)
(defvar url-current-object)
(defgroup mm-url nil
"A wrapper of url package and external url command for Gnus."
:group 'gnus)
(defcustom mm-url-use-external nil
Remove obsolete leading * from defcustom, defface doc strings. * lisp/cedet/ede/linux.el, lisp/cedet/ede/project-am.el: * lisp/cedet/ede/simple.el, lisp/cedet/semantic/bovine/c.el: * lisp/cedet/semantic/complete.el, lisp/cedet/semantic/db.el: * lisp/cedet/semantic/decorate/include.el: * lisp/cedet/semantic/decorate/mode.el, lisp/cedet/semantic/format.el: * lisp/cedet/semantic/ia.el, lisp/cedet/semantic/idle.el: * lisp/cedet/semantic/imenu.el, lisp/cedet/semantic/lex-spp.el: * lisp/cedet/semantic/mru-bookmark.el, lisp/cedet/semantic/sb.el: * lisp/cedet/srecode/fields.el, lisp/ecomplete.el: * lisp/gnus/gnus-agent.el, lisp/gnus/gnus-art.el: * lisp/gnus/gnus-async.el, lisp/gnus/gnus-cache.el: * lisp/gnus/gnus-cite.el, lisp/gnus/gnus-delay.el: * lisp/gnus/gnus-diary.el, lisp/gnus/gnus-dup.el: * lisp/gnus/gnus-fun.el, lisp/gnus/gnus-group.el: * lisp/gnus/gnus-kill.el, lisp/gnus/gnus-msg.el: * lisp/gnus/gnus-picon.el, lisp/gnus/gnus-salt.el: * lisp/gnus/gnus-score.el, lisp/gnus/gnus-start.el: * lisp/gnus/gnus-sum.el, lisp/gnus/gnus-topic.el: * lisp/gnus/gnus-util.el, lisp/gnus/gnus-uu.el, lisp/gnus/gnus-win.el: * lisp/gnus/gnus.el, lisp/gnus/mail-source.el, lisp/gnus/message.el: * lisp/gnus/mm-url.el, lisp/gnus/mm-uu.el, lisp/gnus/mml.el: * lisp/gnus/nndiary.el, lisp/gnus/nnir.el, lisp/gnus/nnmail.el: * lisp/gnus/smiley.el, lisp/gnus/smime.el, lisp/mail/mail-extr.el: * lisp/mh-e/mh-e.el, lisp/net/mailcap.el, lisp/net/pop3.el: * lisp/net/starttls.el, lisp/progmodes/cc-vars.el: * lisp/progmodes/cperl-mode.el, test/manual/cedet/tests/test.el: Remove obsolete leading * from defcustom, defface doc strings.
2016-06-10 00:13:12 +00:00
"If non-nil, use external grab program `mm-url-program'."
:version "22.1"
:type 'boolean)
(defvar mm-url-predefined-programs
'((wget "wget" "--user-agent=mm-url" "-q" "-O" "-")
(w3m "w3m" "-dump_source")
(lynx "lynx" "-source")
(curl "curl" "--silent" "--user-agent" "mm-url" "--location")))
(defcustom mm-url-program
(cond
((executable-find "wget") 'wget)
((executable-find "w3m") 'w3m)
((executable-find "lynx") 'lynx)
((executable-find "curl") 'curl)
(t "GET"))
"The url grab program.
Likely values are `wget', `w3m', `lynx' and `curl'."
:version "22.1"
:type '(choice
(symbol :tag "wget" wget)
(symbol :tag "w3m" w3m)
(symbol :tag "lynx" lynx)
(symbol :tag "curl" curl)
(string :tag "other")))
(defcustom mm-url-arguments nil
"The arguments for `mm-url-program'."
:version "22.1"
:type '(repeat string))
;;; Internal variables
;; Stolen from w3.
(defvar mm-url-html-entities
'(
;;(excl . 33)
(quot . 34)
;;(num . 35)
;;(dollar . 36)
;;(percent . 37)
(amp . 38)
(rsquo . 39) ; should be U+8217
;;(apos . 39)
;;(lpar . 40)
;;(rpar . 41)
;;(ast . 42)
;;(plus . 43)
;;(comma . 44)
;;(period . 46)
;;(colon . 58)
;;(semi . 59)
(lt . 60)
;;(equals . 61)
(gt . 62)
;;(quest . 63)
;;(commat . 64)
;;(lsqb . 91)
;;(rsqb . 93)
(uarr . 94) ; should be U+8593
;;(lowbar . 95)
(lsquo . 96) ; should be U+8216
(lcub . 123)
;;(verbar . 124)
(rcub . 125)
(tilde . 126)
(nbsp . 160)
(iexcl . 161)
(cent . 162)
(pound . 163)
(curren . 164)
(yen . 165)
(brvbar . 166)
(sect . 167)
(uml . 168)
(copy . 169)
(ordf . 170)
(laquo . 171)
(not . 172)
(shy . 173)
(reg . 174)
(macr . 175)
(deg . 176)
(plusmn . 177)
(sup2 . 178)
(sup3 . 179)
(acute . 180)
(micro . 181)
(para . 182)
(middot . 183)
(cedil . 184)
(sup1 . 185)
(ordm . 186)
(raquo . 187)
(frac14 . 188)
(frac12 . 189)
(frac34 . 190)
(iquest . 191)
(Agrave . 192)
(Aacute . 193)
(Acirc . 194)
(Atilde . 195)
(Auml . 196)
(Aring . 197)
(AElig . 198)
(Ccedil . 199)
(Egrave . 200)
(Eacute . 201)
(Ecirc . 202)
(Euml . 203)
(Igrave . 204)
(Iacute . 205)
(Icirc . 206)
(Iuml . 207)
(ETH . 208)
(Ntilde . 209)
(Ograve . 210)
(Oacute . 211)
(Ocirc . 212)
(Otilde . 213)
(Ouml . 214)
(times . 215)
(Oslash . 216)
(Ugrave . 217)
(Uacute . 218)
(Ucirc . 219)
(Uuml . 220)
(Yacute . 221)
(THORN . 222)
(szlig . 223)
(agrave . 224)
(aacute . 225)
(acirc . 226)
(atilde . 227)
(auml . 228)
(aring . 229)
(aelig . 230)
(ccedil . 231)
(egrave . 232)
(eacute . 233)
(ecirc . 234)
(euml . 235)
(igrave . 236)
(iacute . 237)
(icirc . 238)
(iuml . 239)
(eth . 240)
(ntilde . 241)
(ograve . 242)
(oacute . 243)
(ocirc . 244)
(otilde . 245)
(ouml . 246)
(divide . 247)
(oslash . 248)
(ugrave . 249)
(uacute . 250)
(ucirc . 251)
(uuml . 252)
(yacute . 253)
(thorn . 254)
(yuml . 255)
;; Special handling of these
(frac56 . "5/6")
(frac16 . "1/6")
(frac45 . "4/5")
(frac35 . "3/5")
(frac25 . "2/5")
(frac15 . "1/5")
(frac23 . "2/3")
(frac13 . "1/3")
(frac78 . "7/8")
(frac58 . "5/8")
(frac38 . "3/8")
(frac18 . "1/8")
;; The following 5 entities are not mentioned in the HTML 2.0
;; standard, nor in any other HTML proposed standard of which I
;; am aware. I am not even sure they are ISO entity names. ***
;; Hence, some arrangement should be made to give a bad HTML
;; message when they are seen.
(ndash . 45)
(mdash . 45)
(emsp . 32)
(ensp . 32)
(sim . 126)
(le . "<=")
(agr . "alpha")
(rdquo . "''")
(ldquo . "``")
(trade . "(TM)")
;; To be done
;; (shy . ????) ; soft hyphen
)
Leading "*" in the doc of defvars is long obsolete. * lisp/plstore.el (plstore-encrypt-to): * lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-macro-max-length-to-save): * lisp/cedet/semantic/symref.el (semantic-symref-tool): * lisp/cedet/semantic/bovine/el.el (semantic-elisp-store-documentation-in-tag): * lisp/cedet/semantic/wisent/comp.el (wisent-verbose-flag) (wisent-expected-conflicts): * lisp/cedet/semantic/wisent/wisent.el (wisent-parse-verbose-flag): * lisp/gnus/gnus-agent.el (gnus-category-menu-hook): * lisp/gnus/gnus-group.el (gnus-group-listing-limit): * lisp/gnus/gnus-srvr.el (gnus-server-menu-hook) (gnus-browse-menu-hook): * lisp/gnus/message.el (message-shoot-gnksa-feet): * lisp/gnus/mm-decode.el (mm-path-name-rewrite-functions): * lisp/gnus/mm-util.el (mm-extra-numeric-entities): * lisp/gnus/mm-view.el (mm-w3m-standalone-supports-m17n-p): * lisp/gnus/mml.el (mml-generate-multipart-alist): * lisp/gnus/nndraft.el (nndraft-required-headers): * lisp/gnus/nnheader.el (nnheader-max-head-length) (nnheader-head-chop-length, nnheader-file-name-translation-alist) (nnheader-directory-separator-character) (nnheader-pathname-coding-system): * lisp/gnus/nnmail.el (nnmail-pathname-coding-system) (nnmail-active-file-coding-system): * lisp/gnus/nnrss.el (nnrss-file-coding-system): * lisp/gnus/nntp.el (nntp-record-commands): * lisp/gnus/score-mode.el (gnus-score-edit-done-hook) (gnus-score-mode-hook, gnus-score-menu-hook): * lisp/mail/rfc2047.el (rfc2047-header-encoding-alist) (rfc2047-allow-irregular-q-encoded-words) (rfc2047-allow-incomplete-encoded-text): * lisp/mh-e/mh-alias.el (mh-alias-system-aliases): * lisp/mh-e/mh-e.el (mh-mail-header-separator, mh-x-mailer-string): * lisp/mh-e/mh-scan.el (mh-scan-format-mh, mh-scan-format-nmh): * lisp/net/pop3.el (pop3-password): * lisp/play/animate.el (animate-n-steps): * lisp/progmodes/cc-vars.el (c-old-style-variable-behavior): Convert from defvar with leading * to defcustom. ; * lisp/cedet/semantic/lex.el: Comments. * lisp/emulation/viper-init.el (viper-heading-end): * lisp/gnus/mm-url.el (mm-url-html-entities): * lisp/gnus/nnmaildir.el (nnmaildir-article-file-name): * lisp/mh-e/mh-e.el (mh-invisible-header-fields-compiled): * lisp/net/tramp-adb.el (tramp-adb-method): Remove leading * from doc. * lisp/gnus/messcompat.el: Mark (pointless) file not for compilation. (message-from-style, message-interactive, message-indentation-spaces) (message-signature, message-signature-file): Remove settings that match the defaults. (message-setup-hook, message-mode-hook, message-default-headers) (message-send-hook, message-send-mail-function): Just use setq rather than redefining. * lisp/gnus/nnrss.el (nnrss): * lisp/mail/rfc2047.el (rfc2047): * lisp/play/animate.el (animate): New custom groups.
2016-06-10 04:23:33 +00:00
"An assoc list of entity names and how to actually display them.")
(defconst mm-url-unreserved-chars
'(
?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z
?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z
?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
?- ?_ ?. ?! ?~ ?* ?' ?\( ?\))
"A list of characters that are _NOT_ reserved in the URL spec.
This is taken from RFC 2396.")
(defun mm-url-load-url ()
"Load `url-insert-file-contents'."
(unless (condition-case ()
(progn
(require 'url-handlers)
(require 'url-parse)
(require 'url-vars))
(error nil))
(require 'url)))
;;;###autoload
(defun mm-url-insert-file-contents (url)
"Insert file contents of URL.
If `mm-url-use-external' is non-nil, use `mm-url-program'."
(if mm-url-use-external
(progn
(if (string-match "^file:/+" url)
(insert-file-contents (substring url (1- (match-end 0))))
(mm-url-insert-file-contents-external url))
(goto-char (point-min))
(setq url-current-object (url-generic-parse-url url))
(list url (buffer-size)))
(mm-url-load-url)
(let ((name buffer-file-name)
result)
(setq result (url-insert-file-contents url))
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\r 1000\r ?" nil t)
(replace-match "")))
(setq buffer-file-name name)
(when (listp result)
(setq url-current-object
(url-generic-parse-url (car result))))
result)))
;;;###autoload
(defun mm-url-insert-file-contents-external (url)
"Insert file contents of URL using `mm-url-program'."
(let (program args)
(if (symbolp mm-url-program)
(let ((item (cdr (assq mm-url-program mm-url-predefined-programs))))
(setq program (car item)
args (append (cdr item) (list url))))
(setq program mm-url-program
args (append mm-url-arguments (list url))))
* lisp/gnus: Quote functions with #' To get better warnings, try and use #' to quote function names. * lisp/gnus/canlock.el: * lisp/gnus/deuglify.el: * lisp/gnus/gmm-utils.el: * lisp/gnus/gnus-agent.el: * lisp/gnus/gnus-art.el: * lisp/gnus/gnus-bookmark.el: * lisp/gnus/gnus-cache.el: * lisp/gnus/gnus-cite.el: * lisp/gnus/gnus-cus.el: * lisp/gnus/gnus-delay.el: * lisp/gnus/gnus-diary.el: * lisp/gnus/gnus-dired.el: * lisp/gnus/gnus-draft.el: * lisp/gnus/gnus-fun.el: * lisp/gnus/gnus-group.el: * lisp/gnus/gnus-html.el: * lisp/gnus/gnus-int.el: * lisp/gnus/gnus-kill.el: * lisp/gnus/gnus-mlspl.el: * lisp/gnus/gnus-msg.el: * lisp/gnus/gnus-notifications.el: * lisp/gnus/gnus-picon.el: * lisp/gnus/gnus-registry.el: * lisp/gnus/gnus-rfc1843.el: * lisp/gnus/gnus-salt.el: * lisp/gnus/gnus-score.el: * lisp/gnus/gnus-search.el: * lisp/gnus/gnus-sieve.el: * lisp/gnus/gnus-srvr.el: * lisp/gnus/gnus-start.el: * lisp/gnus/gnus-topic.el: * lisp/gnus/gnus-undo.el: * lisp/gnus/gnus-util.el: * lisp/gnus/gnus-uu.el: * lisp/gnus/gnus.el: * lisp/gnus/mail-source.el: * lisp/gnus/message.el: * lisp/gnus/mm-archive.el: * lisp/gnus/mm-decode.el: * lisp/gnus/mm-url.el: * lisp/gnus/mm-util.el: * lisp/gnus/mm-view.el: * lisp/gnus/mml-sec.el: * lisp/gnus/mml-smime.el: * lisp/gnus/mml.el: * lisp/gnus/nnagent.el: * lisp/gnus/nndiary.el: * lisp/gnus/nndoc.el: * lisp/gnus/nndraft.el: * lisp/gnus/nnfolder.el: * lisp/gnus/nnheader.el: * lisp/gnus/nnmail.el: * lisp/gnus/nnmaildir.el: * lisp/gnus/nnmairix.el: * lisp/gnus/nnmh.el: * lisp/gnus/nnml.el: * lisp/gnus/nnrss.el: * lisp/gnus/nnselect.el: * lisp/gnus/nnspool.el: * lisp/gnus/nnvirtual.el: * lisp/gnus/nnweb.el: * lisp/gnus/smiley.el: * lisp/gnus/smime.el: * lisp/gnus/spam-report.el: * lisp/gnus/spam-stat.el: * lisp/gnus/spam-wash.el: * lisp/gnus/spam.el:
2021-01-30 05:35:24 +00:00
(unless (eq 0 (apply #'call-process program nil t nil args))
(error "Couldn't fetch %s" url))))
(defvar mm-url-timeout 30
"The number of seconds before timing out an URL fetch.")
(defvar mm-url-retries 10
"The number of retries after timing out when fetching an URL.")
(defun mm-url-insert (url &optional follow-refresh)
"Insert the contents from an URL in the current buffer.
If FOLLOW-REFRESH is non-nil, redirect refresh url in META."
(let ((times mm-url-retries)
(done nil)
(first t)
result)
gnus: replace cl with cl-lib * lisp/gnus/gnus-agent.el, lisp/gnus/gnus-art.el: * lisp/gnus/gnus-async.el, lisp/gnus/gnus-cache.el: * lisp/gnus/gnus-demon.el, lisp/gnus/gnus-group.el: * lisp/gnus/gnus-icalendar.el, lisp/gnus/gnus-logic.el: * lisp/gnus/gnus-msg.el, lisp/gnus/gnus-picon.el: * lisp/gnus/gnus-registry.el, lisp/gnus/gnus-salt.el: * lisp/gnus/gnus-score.el, lisp/gnus/gnus-spec.el: * lisp/gnus/gnus-srvr.el, lisp/gnus/gnus-start.el: * lisp/gnus/gnus-sum.el, lisp/gnus/gnus-topic.el: * lisp/gnus/gnus-util.el, lisp/gnus/gnus-uu.el, lisp/gnus/gnus-win.el: * lisp/gnus/mail-source.el, lisp/gnus/mm-decode.el: * lisp/gnus/mm-encode.el, lisp/gnus/mm-url.el, lisp/gnus/mm-view.el: * lisp/gnus/mml-smime.el, lisp/gnus/mml.el, lisp/gnus/mml2015.el: * lisp/gnus/nnbabyl.el, lisp/gnus/nndoc.el, lisp/gnus/nneething.el: * lisp/gnus/nnheader.el, lisp/gnus/nnimap.el, lisp/gnus/nnmail.el: * lisp/gnus/nnmaildir.el, lisp/gnus/nnoo.el, lisp/gnus/nnrss.el: * lisp/gnus/nnspool.el, lisp/gnus/nntp.el, lisp/gnus/nnvirtual.el: * lisp/gnus/nnweb.el, lisp/gnus/spam.el: Replace cl with cl-lib. * lisp/gnus/canlock.el, lisp/gnus/gnus-bcklg.el: * lisp/gnus/gnus-cite.el, lisp/gnus/gnus-cloud.el: * lisp/gnus/gnus-draft.el, lisp/gnus/gnus-dup.el: * lisp/gnus/gnus-fun.el, lisp/gnus/gnus-html.el: * lisp/gnus/gnus-int.el, lisp/gnus/gnus-kill.el, lisp/gnus/gnus-ml.el: * lisp/gnus/gnus-mlspl.el, lisp/gnus/gnus-range.el: * lisp/gnus/gnus-undo.el, lisp/gnus/gnus-vm.el: * lisp/gnus/mm-partial.el, lisp/gnus/mm-uu.el, lisp/gnus/mml1991.el: * lisp/gnus/nnagent.el, lisp/gnus/nndiary.el, lisp/gnus/nndir.el: * lisp/gnus/nndraft.el, lisp/gnus/nnfolder.el, lisp/gnus/nngateway.el: * lisp/gnus/nnmairix.el, lisp/gnus/nnmbox.el, lisp/gnus/nnmh.el: * lisp/gnus/nnml.el, lisp/gnus/score-mode.el, lisp/gnus/smiley.el: No need for cl.
2018-03-23 20:13:09 +00:00
(while (and (not (zerop (cl-decf times)))
(not done))
(with-timeout (mm-url-timeout)
(unless first
(message "Trying again (%s)..." (- mm-url-retries times)))
(setq first nil)
(if follow-refresh
(save-restriction
(narrow-to-region (point) (point))
(mm-url-insert-file-contents url)
(goto-char (point-min))
(when (re-search-forward
"<meta[ \t\r\n]*http-equiv=\"Refresh\"[^>]*URL=\\([^\"]+\\)\"" nil t)
(let ((url (match-string 1)))
(delete-region (point-min) (point-max))
(setq result (mm-url-insert url t)))))
(setq result (mm-url-insert-file-contents url)))
(setq done t)))
result))
(defun mm-url-decode-entities ()
"Decode all HTML entities."
(goto-char (point-min))
(while (re-search-forward "&\\(#[0-9]+\\|#x[0-9a-f]+\\|[a-z]+[0-9]*\\);"
nil t)
(let* ((entity (match-string 1))
(elem (if (eq (aref entity 0) ?\#)
(let ((c
;; Hex number: &#x3212
(if (eq (aref entity 1) ?x)
(string-to-number (substring entity 2)
16)
;; Decimal number: &#23
(string-to-number (substring entity 1)))))
(setq c (or (cdr (assq c mm-extra-numeric-entities))
(mm-ucs-to-char c)))
(if (characterp c) c ?#))
(or (cdr (assq (intern entity)
mm-url-html-entities))
?#))))
(unless (stringp elem)
(setq elem (char-to-string elem)))
(replace-match elem t t))))
(defun mm-url-decode-entities-nbsp ()
"Decode all HTML entities and &nbsp; to a space."
(let ((mm-url-html-entities (cons '(nbsp . 32) mm-url-html-entities)))
(mm-url-decode-entities)))
(defun mm-url-decode-entities-string (string)
(with-temp-buffer
(insert string)
(mm-url-decode-entities)
(buffer-string)))
(defun mm-url-form-encode-xwfu (chunk)
"Escape characters in a string for application/x-www-form-urlencoded.
Blasphemous crap because someone didn't think %20 was good enough for encoding
spaces. Die Die Die."
;; This will get rid of the 'attributes' specified by the file type,
;; which are useless for an application/x-www-form-urlencoded form.
(if (consp chunk)
(setq chunk (cdr chunk)))
(if chunk
(mapconcat
(lambda (char)
(cond
((= char ? ) "+")
((memq char mm-url-unreserved-chars) (char-to-string char))
(t (upcase (format "%%%02x" char)))))
(encode-coding-string chunk (car (find-coding-systems-string chunk)))
"")))
(defun mm-url-encode-www-form-urlencoded (pairs)
"Return PAIRS encoded for forms."
(mapconcat
(lambda (data)
(concat (mm-url-form-encode-xwfu (car data)) "="
(mm-url-form-encode-xwfu (cdr data))))
pairs "&"))
(autoload 'mml-compute-boundary "mml")
(defun mm-url-encode-multipart-form-data (data &optional boundary)
"Return DATA encoded in multipart/form-data.
DATA is a list where the elements can have the following form:
(\"NAME\" . \"VALUE\")
(\"submit\")
(\"file\" . ((\"name\" . \"NAME\")
(\"filename\" . \"FILENAME\")
(\"content-type\" . \"CONTENT-TYPE\")
(\"filedata\" . \"FILEDATA\")))
Lowercase strings above are literals and uppercase are not."
;; RFC1867
;; Get a good boundary.
(unless boundary
(setq boundary (mml-compute-boundary '())))
(with-temp-buffer
(set-buffer-multibyte nil)
(dolist (elem data)
(let ((name (car elem))
(value (cdr elem)))
(insert "--" boundary "\r\n")
(cond
((equal name "file")
(insert (format
"Content-Disposition: form-data; name=%S; filename=%S\r\n"
(or (cdr (assoc "name" value)) name)
(cdr (assoc "filename" value))))
(insert "Content-Transfer-Encoding: binary\r\n")
(insert (format "Content-Type: %s\r\n\r\n"
(or (cdr (assoc "content-type" value))
"text/plain")))
(let ((filedata (cdr (assoc "filedata" value))))
(cond
((stringp filedata)
(insert filedata))
;; How can this possibly be useful?
((integerp filedata)
(insert (number-to-string filedata))))))
((equal name "submit")
(insert
"Content-Disposition: form-data; name=\"submit\"\r\n\r\nSubmit\r\n"))
(t
(insert (format "Content-Disposition: form-data; name=%S\r\n\r\n"
name))
(insert value)))
(unless (bolp)
(insert "\r\n"))))
(insert "--" boundary "--\r\n")
(buffer-string)))
(defun mm-url-remove-markup ()
"Remove all HTML markup, leaving just plain text."
(goto-char (point-min))
(while (search-forward "<!--" nil t)
(delete-region (match-beginning 0)
(or (search-forward "-->" nil t)
(point-max))))
(goto-char (point-min))
(while (re-search-forward "<[^>]+>" nil t)
(replace-match "" t t)))
(provide 'mm-url)
;;; mm-url.el ends here