2020-10-28 03:22:12 +01:00
|
|
|
;;; netrc.el --- .netrc parsing functionality -*- lexical-binding: t -*-
|
|
|
|
|
2021-01-01 01:13:56 -08:00
|
|
|
;; Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
2002-04-24 16:09:22 +00:00
|
|
|
|
|
|
|
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
|
|
|
;; Keywords: news
|
2010-03-14 23:15:02 +02:00
|
|
|
;;
|
2002-04-24 16:09:22 +00:00
|
|
|
;; Modularized by Ted Zlatanov <tzz@lifelogs.com>
|
|
|
|
;; when it was part of Gnus.
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 07:31:51 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2002-04-24 16:09:22 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:31:51 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2002-04-24 16:09:22 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-05-06 07:31:51 +00:00
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2002-04-24 16:09:22 +00:00
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2002-04-24 16:09:22 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; Just the .netrc parsing functionality, abstracted so other packages
|
|
|
|
;; besides Gnus can use it.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
;;;
|
2007-10-28 09:18:39 +00:00
|
|
|
;;; .netrc and .authinfo rc parsing
|
2002-04-24 16:09:22 +00:00
|
|
|
;;;
|
|
|
|
|
2007-10-28 09:18:39 +00:00
|
|
|
(defgroup netrc nil
|
|
|
|
"Netrc configuration."
|
|
|
|
:group 'comm)
|
|
|
|
|
2010-09-11 00:36:27 +00:00
|
|
|
(defcustom netrc-file "~/.authinfo"
|
|
|
|
"File where user credentials are stored."
|
Add missing :version tags to new defgroups and defcustoms
* window.el (window-sides-slots):
* tool-bar.el (tool-bar-position):
* term/xterm.el (xterm-extra-capabilities):
* ses.el (ses-self-reference-early-detection):
* progmodes/verilog-mode.el (verilog-auto-declare-nettype)
(verilog-auto-wire-type)
(verilog-auto-delete-trailing-whitespace)
(verilog-auto-reset-blocking-in-non, verilog-auto-inst-sort)
(verilog-auto-tieoff-declaration):
* progmodes/sql.el (sql-login-hook, sql-ansi-statement-starters)
(sql-oracle-statement-starters, sql-oracle-scan-on):
* progmodes/prolog.el (prolog-align-comments-flag)
(prolog-indent-mline-comments-flag, prolog-object-end-to-0-flag)
(prolog-left-indent-regexp, prolog-paren-indent-p)
(prolog-paren-indent, prolog-parse-mode, prolog-keywords)
(prolog-types, prolog-mode-specificators)
(prolog-determinism-specificators, prolog-directives)
(prolog-electric-newline-flag, prolog-hungry-delete-key-flag)
(prolog-electric-dot-flag)
(prolog-electric-dot-full-predicate-template)
(prolog-electric-underscore-flag, prolog-electric-tab-flag)
(prolog-electric-if-then-else-flag, prolog-electric-colon-flag)
(prolog-electric-dash-flag, prolog-old-sicstus-keys-flag)
(prolog-program-switches, prolog-prompt-regexp)
(prolog-debug-on-string, prolog-debug-off-string)
(prolog-trace-on-string, prolog-trace-off-string)
(prolog-zip-on-string, prolog-zip-off-string)
(prolog-use-standard-consult-compile-method-flag)
(prolog-use-prolog-tokenizer-flag, prolog-imenu-flag)
(prolog-imenu-max-lines, prolog-info-predicate-index)
(prolog-underscore-wordchar-flag, prolog-use-sicstus-sd)
(prolog-char-quote-workaround):
* progmodes/cc-vars.el (c-defun-tactic):
* net/tramp.el (tramp-encoding-command-interactive)
(tramp-local-end-of-line):
* net/soap-client.el (soap-client):
* net/netrc.el (netrc-file):
* net/gnutls.el (gnutls):
* minibuffer.el (completion-category-overrides)
(completion-cycle-threshold)
(completion-pcm-complete-word-inserts-delimiters):
* man.el (Man-name-local-regexp):
* mail/feedmail.el (feedmail-display-full-frame):
* international/characters.el (glyphless-char-display-control):
* eshell/em-ls.el (eshell-ls-date-format):
* emacs-lisp/cl-indent.el (lisp-lambda-list-keyword-alignment)
(lisp-lambda-list-keyword-parameter-indentation)
(lisp-lambda-list-keyword-parameter-alignment):
* doc-view.el (doc-view-image-width, doc-view-unoconv-program):
* dired-x.el (dired-omit-verbose):
* cus-theme.el (custom-theme-allow-multiple-selections):
* calc/calc.el (calc-highlight-selections-with-faces)
(calc-lu-field-reference, calc-lu-power-reference)
(calc-note-threshold):
* battery.el (battery-mode-line-limit):
* arc-mode.el (archive-7z-extract, archive-7z-expunge)
(archive-7z-update):
* allout.el (allout-prefixed-keybindings)
(allout-unprefixed-keybindings)
(allout-inhibit-auto-fill-on-headline)
(allout-flattened-numbering-abbreviation):
* allout-widgets.el (allout-widgets-auto-activation)
(allout-widgets-icons-dark-subdir)
(allout-widgets-icons-light-subdir, allout-widgets-icon-types)
(allout-widgets-theme-dark-background)
(allout-widgets-theme-light-background)
(allout-widgets-item-image-properties-emacs)
(allout-widgets-item-image-properties-xemacs)
(allout-widgets-run-unit-tests-on-load)
(allout-widgets-time-decoration-activity)
(allout-widgets-hook-error-post-time)
(allout-widgets-track-decoration):
* gnus/sieve-manage.el (sieve-manage-default-stream):
* gnus/shr.el (shr):
* gnus/nnir.el (nnir-ignored-newsgroups, nnir-summary-line-format)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-notmuch-program)
(nnir-notmuch-additional-switches, nnir-notmuch-remove-prefix)
(nnir-method-default-engines):
* gnus/message.el (message-cite-reply-position):
* gnus/gssapi.el (gssapi-program):
* gnus/gravatar.el (gravatar):
* gnus/gnus-sum.el (gnus-refer-thread-use-nnir):
* gnus/gnus-registry.el (gnus-registry-unfollowed-addresses)
(gnus-registry-max-pruned-entries):
* gnus/gnus-picon.el (gnus-picon-inhibit-top-level-domains):
* gnus/gnus-int.el (gnus-after-set-mark-hook)
(gnus-before-update-mark-hook):
* gnus/gnus-async.el (gnus-async-post-fetch-function):
* gnus/auth-source.el (auth-source-cache-expiry):
Add missing :version tags to new defcustoms and defgroups.
2012-02-11 14:13:29 -08:00
|
|
|
:version "24.1"
|
2020-10-28 03:22:12 +01:00
|
|
|
:type 'file)
|
2010-09-11 00:36:27 +00:00
|
|
|
|
2007-10-28 09:18:39 +00:00
|
|
|
(defvar netrc-services-file "/etc/services"
|
|
|
|
"The name of the services file.")
|
2002-04-24 16:09:22 +00:00
|
|
|
|
2010-12-13 22:29:12 +00:00
|
|
|
(defvar netrc-cache nil)
|
|
|
|
|
2010-09-11 00:36:27 +00:00
|
|
|
(defun netrc-parse (&optional file)
|
2008-03-10 00:50:22 +00:00
|
|
|
"Parse FILE and return a list of all entries in the file."
|
2019-12-28 13:40:57 +01:00
|
|
|
(interactive "fFile to Parse: ")
|
2010-09-11 00:36:27 +00:00
|
|
|
(unless file
|
|
|
|
(setq file netrc-file))
|
2008-11-12 08:12:19 +00:00
|
|
|
(if (listp file)
|
2010-12-13 22:29:12 +00:00
|
|
|
;; We got already parsed contents; just return it.
|
2008-11-12 08:12:19 +00:00
|
|
|
file
|
|
|
|
(when (file-exists-p file)
|
|
|
|
(with-temp-buffer
|
|
|
|
(let ((tokens '("machine" "default" "login"
|
|
|
|
"password" "account" "macdef" "force"
|
|
|
|
"port"))
|
|
|
|
alist elem result pair)
|
2010-12-13 22:29:12 +00:00
|
|
|
(if (and netrc-cache
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
(equal (car netrc-cache) (file-attribute-modification-time
|
|
|
|
(file-attributes file))))
|
2010-12-13 22:29:12 +00:00
|
|
|
(insert (base64-decode-string (rot13-string (cdr netrc-cache))))
|
|
|
|
(insert-file-contents file)
|
|
|
|
(when (string-match "\\.gpg\\'" file)
|
2011-02-21 13:29:15 +00:00
|
|
|
;; Store the contents of the file heavily encrypted in memory.
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
(setq netrc-cache (cons (file-attribute-modification-time
|
|
|
|
(file-attributes file))
|
2010-12-13 22:29:12 +00:00
|
|
|
(rot13-string
|
|
|
|
(base64-encode-string
|
|
|
|
(buffer-string)))))))
|
2008-11-12 08:12:19 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
;; Go through the file, line by line.
|
2002-04-24 16:09:22 +00:00
|
|
|
(while (not (eobp))
|
2008-11-12 08:12:19 +00:00
|
|
|
(narrow-to-region (point) (point-at-eol))
|
|
|
|
;; For each line, get the tokens and values.
|
|
|
|
(while (not (eobp))
|
|
|
|
(skip-chars-forward "\t ")
|
|
|
|
;; Skip lines that begin with a "#".
|
|
|
|
(if (eq (char-after) ?#)
|
|
|
|
(goto-char (point-max))
|
|
|
|
(unless (eobp)
|
|
|
|
(setq elem
|
|
|
|
(if (= (following-char) ?\")
|
|
|
|
(read (current-buffer))
|
|
|
|
(buffer-substring
|
|
|
|
(point) (progn (skip-chars-forward "^\t ")
|
|
|
|
(point)))))
|
|
|
|
(cond
|
|
|
|
((equal elem "macdef")
|
|
|
|
;; We skip past the macro definition.
|
|
|
|
(widen)
|
|
|
|
(while (and (zerop (forward-line 1))
|
|
|
|
(looking-at "$")))
|
|
|
|
(narrow-to-region (point) (point)))
|
|
|
|
((member elem tokens)
|
|
|
|
;; Tokens that don't have a following value are ignored,
|
|
|
|
;; except "default".
|
|
|
|
(when (and pair (or (cdr pair)
|
|
|
|
(equal (car pair) "default")))
|
|
|
|
(push pair alist))
|
|
|
|
(setq pair (list elem)))
|
|
|
|
(t
|
|
|
|
;; Values that haven't got a preceding token are ignored.
|
|
|
|
(when pair
|
|
|
|
(setcdr pair elem)
|
|
|
|
(push pair alist)
|
|
|
|
(setq pair nil)))))))
|
|
|
|
(when alist
|
|
|
|
(push (nreverse alist) result))
|
|
|
|
(setq alist nil
|
|
|
|
pair nil)
|
|
|
|
(widen)
|
|
|
|
(forward-line 1))
|
|
|
|
(nreverse result))))))
|
2002-04-24 16:09:22 +00:00
|
|
|
|
|
|
|
(defun netrc-machine (list machine &optional port defaultport)
|
|
|
|
"Return the netrc values from LIST for MACHINE or for the default entry.
|
|
|
|
If PORT specified, only return entries with matching port tokens.
|
|
|
|
Entries without port tokens default to DEFAULTPORT."
|
|
|
|
(let ((rest list)
|
|
|
|
result)
|
|
|
|
(while list
|
|
|
|
(when (equal (cdr (assoc "machine" (car list))) machine)
|
|
|
|
(push (car list) result))
|
|
|
|
(pop list))
|
|
|
|
(unless result
|
|
|
|
;; No machine name matches, so we look for default entries.
|
|
|
|
(while rest
|
|
|
|
(when (assoc "default" (car rest))
|
2010-10-01 00:25:50 +00:00
|
|
|
(let ((elem (car rest)))
|
|
|
|
(setq elem (delete (assoc "default" elem) elem))
|
|
|
|
(push elem result)))
|
2002-04-24 16:09:22 +00:00
|
|
|
(pop rest)))
|
|
|
|
(when result
|
|
|
|
(setq result (nreverse result))
|
2010-10-01 00:25:50 +00:00
|
|
|
(if (not port)
|
|
|
|
(car result)
|
|
|
|
(while (and result
|
|
|
|
(not (netrc-port-equal
|
|
|
|
(or port defaultport "nntp")
|
|
|
|
;; when port is not given in the netrc file,
|
|
|
|
;; it should mean "any port"
|
|
|
|
(or (netrc-get (car result) "port")
|
|
|
|
defaultport port))))
|
|
|
|
(pop result))
|
|
|
|
(car result)))))
|
2002-04-24 16:09:22 +00:00
|
|
|
|
2007-10-28 09:18:39 +00:00
|
|
|
(defun netrc-machine-user-or-password (mode authinfo-file-or-list machines ports defaults)
|
|
|
|
"Get the user name or password according to MODE from AUTHINFO-FILE-OR-LIST.
|
|
|
|
Matches a machine from MACHINES and a port from PORTS, giving
|
|
|
|
default ports DEFAULTS to `netrc-machine'.
|
|
|
|
|
|
|
|
MODE can be \"login\" or \"password\", suitable for passing to
|
|
|
|
`netrc-get'."
|
|
|
|
(let ((authinfo-list (if (stringp authinfo-file-or-list)
|
|
|
|
(netrc-parse authinfo-file-or-list)
|
|
|
|
authinfo-file-or-list))
|
|
|
|
(ports (or ports '(nil)))
|
|
|
|
(defaults (or defaults '(nil)))
|
|
|
|
info)
|
2009-02-05 02:34:34 +00:00
|
|
|
(if (listp mode)
|
2010-09-02 01:42:32 +00:00
|
|
|
(setq info
|
|
|
|
(mapcar
|
|
|
|
(lambda (mode-element)
|
2009-02-05 02:34:34 +00:00
|
|
|
(netrc-machine-user-or-password
|
|
|
|
mode-element
|
|
|
|
authinfo-list
|
|
|
|
machines
|
|
|
|
ports
|
|
|
|
defaults))
|
|
|
|
mode))
|
|
|
|
(dolist (machine machines)
|
|
|
|
(dolist (default defaults)
|
|
|
|
(dolist (port ports)
|
|
|
|
(let ((alist (netrc-machine authinfo-list machine port default)))
|
|
|
|
(setq info (or (netrc-get alist mode) info)))))))
|
2007-10-28 09:18:39 +00:00
|
|
|
info))
|
|
|
|
|
2002-04-24 16:09:22 +00:00
|
|
|
(defun netrc-get (alist type)
|
|
|
|
"Return the value of token TYPE from ALIST."
|
|
|
|
(cdr (assoc type alist)))
|
|
|
|
|
2007-10-28 09:18:39 +00:00
|
|
|
(defun netrc-port-equal (port1 port2)
|
|
|
|
(when (numberp port1)
|
|
|
|
(setq port1 (or (netrc-find-service-name port1) port1)))
|
|
|
|
(when (numberp port2)
|
|
|
|
(setq port2 (or (netrc-find-service-name port2) port2)))
|
|
|
|
(equal port1 port2))
|
|
|
|
|
|
|
|
(defun netrc-parse-services ()
|
|
|
|
(when (file-exists-p netrc-services-file)
|
|
|
|
(let ((services nil))
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents netrc-services-file)
|
|
|
|
(while (search-forward "#" nil t)
|
|
|
|
(delete-region (1- (point)) (point-at-eol)))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward
|
|
|
|
"^ *\\([^ \n\t]+\\)[ \t]+\\([0-9]+\\)/\\([^ \t\n]+\\)" nil t)
|
|
|
|
(push (list (match-string 1) (string-to-number (match-string 2))
|
|
|
|
(intern (downcase (match-string 3))))
|
|
|
|
services))
|
|
|
|
(nreverse services)))))
|
|
|
|
|
|
|
|
(defun netrc-find-service-name (number &optional type)
|
|
|
|
(let ((services (netrc-parse-services))
|
|
|
|
service)
|
|
|
|
(setq type (or type 'tcp))
|
|
|
|
(while (and (setq service (pop services))
|
|
|
|
(not (and (= number (cadr service))
|
2007-12-02 18:57:36 +00:00
|
|
|
(eq type (car (cddr service)))))))
|
2007-10-28 09:18:39 +00:00
|
|
|
(car service)))
|
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
;;;###autoload
|
2010-09-11 00:36:27 +00:00
|
|
|
(defun netrc-credentials (machine &rest ports)
|
|
|
|
"Return a user name/password pair.
|
2011-12-05 00:55:25 -08:00
|
|
|
Port specifications will be prioritized in the order they are
|
2010-09-11 00:36:27 +00:00
|
|
|
listed in the PORTS list."
|
|
|
|
(let ((list (netrc-parse))
|
|
|
|
found)
|
2010-10-01 00:25:50 +00:00
|
|
|
(if (not ports)
|
|
|
|
(setq found (netrc-machine list machine))
|
|
|
|
(while (and ports
|
|
|
|
(not found))
|
|
|
|
(setq found (netrc-machine list machine (pop ports)))))
|
2010-09-11 00:36:27 +00:00
|
|
|
(when found
|
|
|
|
(list (cdr (assoc "login" found))
|
|
|
|
(cdr (assoc "password" found))))))
|
|
|
|
|
2002-04-24 16:09:22 +00:00
|
|
|
(provide 'netrc)
|
|
|
|
|
|
|
|
;;; netrc.el ends here
|