]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org.el
Simplify now that float-time etc. are built-in
[gnu-emacs] / lisp / org / org.el
index 3e032d4664667a6d98d83c33fc13eeb6d78f30da..e2fbf7bc31437be8ba73aa51bdbc787a92118b75 100644 (file)
@@ -1,7 +1,7 @@
 ;;; org.el --- Outline-based notes management and organizer
 
 ;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
@@ -381,7 +381,7 @@ core modules, nor modules from the CONTRIB directory).  Just add symbols
 to the end of the list.  If the package is called org-xyz.el, then you need
 to add the symbol `xyz', and the package must have a call to:
 
-   \(provide 'org-xyz)
+   (provide \\='org-xyz)
 
 For export specific modules, see also `org-export-backends'."
   :group 'org
@@ -465,26 +465,26 @@ need to make a change while Emacs is running, use the customize
 interface or run the following code, where VAL stands for the new
 value of the variable, after updating it:
 
-  \(progn
-    \(setq org-export--registered-backends
-          \(org-remove-if-not
-           \(lambda (backend)
-             \(let ((name (org-export-backend-name backend)))
-               \(or (memq name val)
-                   \(catch 'parentp
-                     \(dolist (b val)
-                       \(and (org-export-derived-backend-p b name)
-                            \(throw 'parentp t)))))))
+  (progn
+    (setq org-export--registered-backends
+          (org-remove-if-not
+           (lambda (backend)
+             (let ((name (org-export-backend-name backend)))
+               (or (memq name val)
+                   (catch \\='parentp
+                     (dolist (b val)
+                       (and (org-export-derived-backend-p b name)
+                            (throw \\='parentp t)))))))
            org-export--registered-backends))
-    \(let ((new-list (mapcar 'org-export-backend-name
+    (let ((new-list (mapcar \\='org-export-backend-name
                             org-export--registered-backends)))
-      \(dolist (backend val)
-        \(cond
-         \((not (load (format \"ox-%s\" backend) t t))
-          \(message \"Problems while trying to load export back-end `%s'\"
+      (dolist (backend val)
+        (cond
+         ((not (load (format \"ox-%s\" backend) t t))
+          (message \"Problems while trying to load export back-end \\=`%s\\='\"
                    backend))
-         \((not (memq backend new-list)) (push backend new-list))))
-      \(set-default 'org-export-backends new-list)))
+         ((not (memq backend new-list)) (push backend new-list))))
+      (set-default \\='org-export-backends new-list)))
 
 Adding a back-end to this list will also pull the back-end it
 depends on, if any."
@@ -595,7 +595,7 @@ XEmacs user should have this variable set to nil, because
 (defcustom org-loop-over-headlines-in-active-region nil
   "Shall some commands act upon headlines in the active region?
 
-When set to `t', some commands will be performed in all headlines
+When set to t, some commands will be performed in all headlines
 within the active region.
 
 When set to `start-level', some commands will be performed in all
@@ -827,7 +827,7 @@ When nil, just use the standard three dots.
 When a string, use that string instead.
 When a face, use the standard 3 dots, but with the specified face.
 The change affects only Org-mode (which will then use its own display table).
-Changing this requires executing `M-x org-mode RET' in a buffer to become
+Changing this requires executing `\\[org-mode]' in a buffer to become
 effective."
   :group 'org-startup
   :type '(choice (const :tag "Default" nil)
@@ -1452,7 +1452,7 @@ changed by an edit command."
 (defcustom org-remove-highlights-with-change t
   "Non-nil means any change to the buffer will remove temporary highlights.
 Such highlights are created by `org-occur' and `org-clock-display'.
-When nil, `C-c C-c needs to be used to get rid of the highlights.
+When nil, `C-c C-c' needs to be used to get rid of the highlights.
 The highlights created by `org-preview-latex-fragment' always need
 `C-c C-c' to be removed."
   :group 'org-sparse-trees
@@ -1548,8 +1548,8 @@ links in Org-mode buffers can have an optional tag after a double colon, e.g.
 
      [[linkkey:tag][description]]
 
-The 'linkkey' must be a word word, starting with a letter, followed
-by letters, numbers, '-' or '_'.
+The `linkkey' must be a word word, starting with a letter, followed
+by letters, numbers, `-' or `_'.
 
 If REPLACE is a string, the tag will simply be appended to create the link.
 If the string contains \"%s\", the tag will be inserted there.  If the string
@@ -1575,7 +1575,7 @@ See the manual for examples."
   "Non-nil means Org will display descriptive links.
 E.g. [[http://orgmode.org][Org website]] will be displayed as
 \"Org Website\", hiding the link itself and just displaying its
-description.  When set to `nil', Org will display the full links
+description.  When set to nil, Org will display the full links
 literally.
 
 You can interactively set the value of this variable by calling
@@ -1982,7 +1982,7 @@ file identifier are
                  filename matches the regexp.  If you want to
                  use groups here, use shy groups.
 
-                 Example: (\"\\.x?html\\'\" . \"firefox %s\")
+                 Example: (\"\\.x?html\\\\='\" . \"firefox %s\")
                           (\"\\(?:xhtml\\|html\\)\" . \"firefox %s\")
                           to open *.html and *.xhtml with firefox.
 
@@ -1998,7 +1998,7 @@ file identifier are
                  In a custom lisp form, you can access the group matches with
                  (match-string n link).
 
-                 Example: (\"\\.pdf::\\(\\d+\\)\\'\" . \"evince -p %1 %s\")
+                 Example: (\"\\.pdf::\\(\\d+\\)\\\\='\" . \"evince -p %1 %s\")
                      to open [[file:document.pdf::5]] with evince at page 5.
 
  `directory'   Matches a directory
@@ -2254,7 +2254,7 @@ fast, while still showing the whole path to the entry."
   :type 'boolean)
 
 (defcustom org-refile-allow-creating-parent-nodes nil
-  "Non-nil means allow to create new nodes as refile targets.
+  "Non-nil means allow the creation of new nodes as refile targets.
 New nodes are then created by adding \"/new node name\" to the completion
 of an existing node.  When the value of this variable is `confirm',
 new node creation must be confirmed by the user (recommended).
@@ -2487,7 +2487,7 @@ TODO state changes
 ------------------
 :type  todo-state-change
 :from  previous state (keyword as a string), or nil, or a symbol
-       'todo' or 'done', to indicate the general type of state.
+       `todo' or `done', to indicate the general type of state.
 :to    new state, like in :from")
 
 (defcustom org-enforce-todo-dependencies nil
@@ -2957,7 +2957,7 @@ its value is 0.
 
 For example,
 
-  \(:days \"%dd\" :hours \"%d\" :require-hours t :minutes \":%02d\"
+   (:days \"%dd\" :hours \"%d\" :require-hours t :minutes \":%02d\"
     :require-minutes t)
 
 means durations longer than a day will be expressed in days,
@@ -2967,7 +2967,7 @@ hour).
 
 The value
 
-  \(:days \"%dd\" :minutes \"%dm\")
+  (:days \"%dd\" :minutes \"%dm\")
 
 means durations longer than a day will be expressed in days and
 minutes, and durations less than a day will be expressed entirely
@@ -3291,10 +3291,10 @@ Instead of customizing this variable directly, you might want to
 set it locally for capture buffers, because there no list of
 tags in that file can be created dynamically (there are none).
 
-  (add-hook 'org-capture-mode-hook
+  (add-hook \\='org-capture-mode-hook
             (lambda ()
               (set (make-local-variable
-                    'org-complete-tags-always-offer-all-agenda-tags)
+                    \\='org-complete-tags-always-offer-all-agenda-tags)
                    t)))"
   :group 'org-tags
   :version "24.1"
@@ -3802,8 +3802,8 @@ images at the same place."
 
 (defcustom org-format-latex-header "\\documentclass{article}
 \\usepackage[usenames]{color}
-\[PACKAGES]
-\[DEFAULT-PACKAGES]
+[PACKAGES]
+[DEFAULT-PACKAGES]
 \\pagestyle{empty}             % do not remove
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
@@ -3889,7 +3889,7 @@ a string.
 
 A cell is of the format:
 
-  \( \"options\" \"package\" SNIPPET-FLAG).
+  ( \"options\" \"package\" SNIPPET-FLAG).
 
 If SNIPPET-FLAG is non-nil, the package also needs to be included
 when compiling LaTeX snippets into images for inclusion into
@@ -3917,7 +3917,7 @@ Each element is either a cell or a string.
 
 A cell is of the format:
 
-    \(\"options\" \"package\" SNIPPET-FLAG)
+    (\"options\" \"package\" SNIPPET-FLAG)
 
 SNIPPET-FLAG, when non-nil, indicates that this package is also
 needed when turning LaTeX snippets into images for inclusion into
@@ -3974,7 +3974,7 @@ lines to the buffer:
 
 (defcustom org-hidden-keywords nil
   "List of symbols corresponding to keywords to be hidden the org buffer.
-For example, a value '(title) for this list will make the document's title
+For example, a value \\='(title) for this list will make the document's title
 appear in the buffer without the initial #+TITLE: keyword."
   :group 'org-appearance
   :version "24.1"
@@ -4346,7 +4346,8 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
       (goto-char (point-min))
       (while (re-search-forward org-table-any-line-regexp nil t)
        (unless quietly
-         (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size))))
+         (message "Mapping tables: %d%%"
+                  (floor (* 100.0 (point)) (buffer-size))))
        (beginning-of-line 1)
        (when (and (looking-at org-table-line-regexp)
                   ;; Exclude tables in src/example/verbatim/clocktable blocks
@@ -4859,8 +4860,8 @@ Support for group tags is controlled by the option
                                             (if (characterp (cdr tg))
                                                 (format "(%s)" (char-to-string (cdr tg))) "")))))
               org-tag-alist)))
-      (let (tgs g)
-       (while (setq e (pop tags))
+      (let (tgs g)
+       (dolist (e tags)
          (cond
           ((equal e "{")
            (progn (push '(:startgroup) tgs)
@@ -4874,7 +4875,8 @@ Support for group tags is controlled by the option
           ((equal e "\\n") (push '(:newline) tgs))
           ((string-match (org-re "^\\([[:alnum:]_@#%]+\\)(\\(.\\))$") e)
            (push (cons (match-string 1 e)
-                       (string-to-char (match-string 2 e))) tgs)
+                       (string-to-char (match-string 2 e)))
+                  tgs)
            (if (and g (> g 0))
                (setcar org-tag-groups-alist
                        (append (car org-tag-groups-alist)
@@ -4886,7 +4888,7 @@ Support for group tags is controlled by the option
                          (append (car org-tag-groups-alist) (list e))))
              (if g (setq g (1+ g))))))
        (org-set-local 'org-tag-alist nil)
-       (while (setq e (pop tgs))
+       (dolist (e tgs)
          (or (and (stringp (car e))
                   (assoc (car e) org-tag-alist))
              (push e org-tag-alist)))
@@ -4956,7 +4958,8 @@ Support for group tags is controlled by the option
             ((string-match "\\`\\([a-zA-Z][0-9a-zA-Z_]*\\)_TODO\\'" key)
              ;; general TODO-like setup
              (push (cons (intern (downcase (match-string 1 key)))
-                         (org-split-string value splitre)) kwds))
+                         (org-split-string value splitre))
+                    kwds))
             ((equal key "COLUMNS")
              (org-set-local 'org-columns-default-format value))
             ((equal key "LINK")
@@ -4977,8 +4980,8 @@ Support for group tags is controlled by the option
              (org-table-set-constants))
             ((equal key "STARTUP")
              (let ((opts (org-split-string value splitre))
-                   var val)
-               (while (setq l (pop opts))
+                   var val)
+               (dolist (l opts)
                  (when (setq l (assoc l org-startup-options))
                    (setq var (nth 1 l) val (nth 2 l))
                    (if (not (nth 3 l))
@@ -5040,8 +5043,8 @@ Support for group tags is controlled by the option
                                   (default-value 'org-todo-keywords)))))
        (setq kwds (reverse kwds)))
       (setq kwds (nreverse kwds))
-      (let (inter kws kw)
-       (while (setq kws (pop kwds))
+      (let (inter kw)
+       (dolist (kws kwds)
          (let ((kws (or
                      (run-hook-with-args-until-success
                       'org-todo-setup-filter-hook kws)
@@ -5209,8 +5212,8 @@ This will extract info from a string like \"WAIT(w@/!)\"."
 (defun org-assign-fast-keys (alist)
   "Assign fast keys to a keyword-key alist.
 Respect keys that are already there."
-  (let (new (alt ?0))
-    (while (setq e (pop alist))
+  (let (new (alt ?0))
+    (dolist (e alist)
       (if (or (memq (car e) '(:newline :grouptags :endgroup :startgroup))
              (cdr e)) ;; Key already assigned.
          (push e new)
@@ -5277,7 +5280,6 @@ This variable is set by `org-before-change-function'.
 
 ;; Other stuff we need.
 (require 'time-date)
-(unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time))
 (require 'easymenu)
 (require 'overlay)
 
@@ -5329,8 +5331,9 @@ The following commands are available:
     (define-key org-mode-map [menu-bar show] 'undefined))
 
   (org-load-modules-maybe)
-  (easy-menu-add org-org-menu)
-  (easy-menu-add org-tbl-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add org-org-menu)
+    (easy-menu-add org-tbl-menu))
   (org-install-agenda-files-menu)
   (if org-descriptive-links (add-to-invisibility-spec '(org-link)))
   (add-to-invisibility-spec '(org-cwidth))
@@ -5510,8 +5513,8 @@ the rounding returns a past time."
            (apply 'encode-time
                   (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r)))))
                           (nthcdr 2 time))))
-      (if (and past (< (org-float-time (time-subtract (current-time) res)) 0))
-         (seconds-to-time (- (org-float-time res) (* r 60)))
+      (if (and past (< (float-time (time-subtract (current-time) res)) 0))
+         (seconds-to-time (- (float-time res) (* r 60)))
        res))))
 
 (defun org-today ()
@@ -6625,7 +6628,7 @@ in special contexts.
        ;; Table: enter it or move to the next field.
        ((org-at-table-p 'any)
        (if (org-at-table.el-p)
-           (message "Use C-c ' to edit table.el tables")
+           (message "%s" "Use C-c ' to edit table.el tables")
          (if arg (org-table-edit-field t)
            (org-table-justify-field-maybe)
            (call-interactively 'org-table-next-field))))
@@ -7090,7 +7093,7 @@ open and agenda-wise Org files."
          (org-flag-drawer t))))))
 
 (defun org-cycle-hide-inline-tasks (state)
-  "Re-hide inline tasks when switching to 'contents or 'children
+  "Re-hide inline tasks when switching to `contents' or `children'
 visibility state."
   (case state
     (contents
@@ -7264,9 +7267,8 @@ Optional arguments START and END can be used to limit the range."
   (setq org-goto-map
        (let ((map (make-sparse-keymap)))
          (let ((cmds '(isearch-forward isearch-backward kill-ring-save set-mark-command
-                                       mouse-drag-region universal-argument org-occur))
-               cmd)
-           (while (setq cmd (pop cmds))
+                                       mouse-drag-region universal-argument org-occur)))
+           (dolist (cmd cmds)
              (substitute-key-definition cmd cmd map global-map)))
          (suppress-keymap map)
          (org-defkey map "\C-m"     'org-goto-ret)
@@ -7299,7 +7301,7 @@ Optional arguments START and END can be used to limit the range."
 (defconst org-goto-help
   "Browse buffer copy, to find location or copy text.%s
 RET=jump to location             C-g=quit and return to previous location
-\[Up]/[Down]=next/prev headline   TAB=cycle visibility   [/] org-occur")
+[Up]/[Down]=next/prev headline   TAB=cycle visibility   [/] org-occur")
 
 (defvar org-goto-start-pos) ; dynamically scoped parameter
 
@@ -7320,8 +7322,8 @@ returns to the original buffer in which the visibility is still
 unchanged.  After RET it will also jump to the location selected
 in the indirect buffer and expose the headline hierarchy above.
 
-With a prefix argument, use the alternative interface: e.g. if
-`org-goto-interface' is 'outline use 'outline-path-completion."
+With a prefix argument, use the alternative interface: e.g., if
+`org-goto-interface' is `outline' use `outline-path-completion'."
   (interactive "P")
   (org-goto-map)
   (let* ((org-refile-targets `((nil . (:maxlevel . ,org-goto-max-level))))
@@ -7679,7 +7681,7 @@ command."
              (re-search-forward org-outline-regexp-bol)
              (beginning-of-line 0))
            (skip-chars-backward " \r\n")
-           (and (not (looking-back "^\*+"))
+           (and (not (looking-back "^\\*+" (line-beginning-position)))
                 (looking-at "[ \t]+") (replace-match ""))
            (unless (eobp) (forward-char 1))
            (when (looking-at "^\\*")
@@ -8563,7 +8565,8 @@ and still retain the repeater to cover future instances of the task."
              (goto-char (point-min))
              (while (re-search-forward drawer-re nil t)
                (mapc (lambda (d)
-                       (org-remove-empty-drawer-at d (point))) org-drawers)))
+                       (org-remove-empty-drawer-at d (point)))
+                      org-drawers)))
            (goto-char (point-min))
            (when doshift
              (while (re-search-forward org-ts-regexp-both nil t)
@@ -8597,7 +8600,8 @@ Optional argument WITH-CASE means sort case-sensitively."
   (while (string-match org-bracket-link-regexp s)
     (setq s (replace-match (if (match-end 2)
                               (match-string 3 s)
-                            (match-string 1 s)) t t s)))
+                            (match-string 1 s))
+                           t t s)))
   (let ((st (format " %s " s)))
     (while (string-match org-emph-re st)
       (setq st (replace-match (format " %s " (match-string 4 st)) t t st)))
@@ -8658,7 +8662,8 @@ links."
         (when (equal (marker-buffer org-clock-marker) (current-buffer))
           (save-excursion
             (goto-char org-clock-marker)
-            (looking-back "^.*") (match-string-no-properties 0))))
+             (buffer-substring-no-properties (line-beginning-position)
+                                             (point)))))
         start beg end stars re re2
         txt what tmp)
     ;; Find beginning and end of region to sort
@@ -8773,24 +8778,24 @@ links."
               (if (or (re-search-forward org-ts-regexp end t)
                       (re-search-forward org-ts-regexp-both end t))
                   (org-time-string-to-seconds (match-string 0))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?c)
             (let ((end (save-excursion (outline-next-heading) (point))))
               (if (re-search-forward
                    (concat "^[ \t]*\\[" org-ts-regexp1 "\\]")
                    end t)
                   (org-time-string-to-seconds (match-string 0))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?s)
             (let ((end (save-excursion (outline-next-heading) (point))))
               (if (re-search-forward org-scheduled-time-regexp end t)
                   (org-time-string-to-seconds (match-string 1))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?d)
             (let ((end (save-excursion (outline-next-heading) (point))))
               (if (re-search-forward org-deadline-time-regexp end t)
                   (org-time-string-to-seconds (match-string 1))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?p)
             (if (re-search-forward org-priority-regexp (point-at-eol) t)
                 (string-to-char (match-string 2))
@@ -8854,7 +8859,7 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
            (lambda (x)
              (if (or (string-match org-ts-regexp x)
                      (string-match org-ts-regexp-both x))
-                 (org-float-time
+                 (float-time
                   (org-time-string-to-time (match-string 0 x)))
                0))
            comparefun (if (= dcst sorting-type) '< '>)))
@@ -9146,10 +9151,11 @@ definitions."
                            (list (car c) (car c) (cadr c)))
                           ((string= "" (cadr c))
                            (list (car c) (car c) (caddr c)))
-                          (t c))) contexts))
-       (a alist) c r s)
+                          (t c)))
+          contexts))
+       (a alist) r s)
     ;; loop over all commands or templates
-    (while (setq c (pop a))
+    (dolist (c a)
       (let (vrules repl)
        (cond
         ((not (assoc (car c) contexts))
@@ -9159,7 +9165,8 @@ definitions."
                             (car c) contexts)))
          (mapc (lambda (vr)
                  (when (not (equal (car vr) (cadr vr)))
-                   (setq repl vr))) vrules)
+                   (setq repl vr)))
+                vrules)
          (if (not repl) (push c r)
            (push (cadr repl) s)
            (push
@@ -9176,14 +9183,16 @@ definitions."
                (let ((tpl (car x)))
                  (when (not (delq
                              nil
-                             (mapcar (lambda(y)
-                                       (equal y tpl)) s))) x)))
+                             (mapcar (lambda (y)
+                                       (equal y tpl))
+                                      s)))
+                    x)))
              (reverse r))))))
 
 (defun org-contextualize-validate-key (key contexts)
   "Check CONTEXTS for agenda or capture KEY."
-  (let (r rr res)
-    (while (setq r (pop contexts))
+  (let (rr res)
+    (dolist (r contexts)
       (mapc
        (lambda (rr)
         (when
@@ -9482,7 +9491,8 @@ active region."
                  (funcall (caar sfuns)))
              (setq link (plist-get org-store-link-plist :link)
                    desc (or (plist-get org-store-link-plist
-                                       :description) link))))
+                                       :description)
+                             link))))
 
        ;; Store a link from a source code buffer
        ((org-src-edit-buffer-p)
@@ -9662,7 +9672,8 @@ active region."
 
        ;; Return the link
        (if (not (and (or (org-called-interactively-p 'any)
-                        executing-kbd-macro) link))
+                        executing-kbd-macro)
+                     link))
           (or agenda-link (and link (org-make-link-string link desc)))
         (push (list link desc) org-stored-links)
         (message "Stored: %s" (or desc link))
@@ -10895,7 +10906,7 @@ visibility around point, thus ignoring
 enclose the position of `org-open-link-marker'."
   (let ((m org-open-link-marker))
     (catch 'exit
-      (while (apply 're-search-forward args)
+      (while (apply #'re-search-forward args)
        (unless (get-text-property (match-end group) 'intangible) ; Emacs 21
          (goto-char (match-end group))
          (if (and (or (not (eq (marker-buffer m) (current-buffer)))
@@ -11175,7 +11186,7 @@ org-open-file.
 It assumes that is the case when the entry uses a regular
 expression which has at least one grouping construct and the
 action is either a lisp form or a command string containing
-'%1', i.e. using at least one subexpression match as a
+`%1', i.e. using at least one subexpression match as a
 parameter."
   (let ((selector (car entry))
        (action (cdr entry)))
@@ -11246,12 +11257,9 @@ on the system \"/user@host:\"."
    ((eq t org-reverse-note-order) t)
    ((not (listp org-reverse-note-order)) nil)
    (t (catch 'exit
-       (let  ((all org-reverse-note-order)
-              entry)
-         (while (setq entry (pop all))
-           (if (string-match (car entry) buffer-file-name)
-               (throw 'exit (cdr entry))))
-         nil)))))
+        (dolist (entry org-reverse-note-order)
+          (if (string-match (car entry) buffer-file-name)
+              (throw 'exit (cdr entry))))))))
 
 (defvar org-refile-target-table nil
   "The list of refile targets, created by `org-refile'.")
@@ -11316,10 +11324,10 @@ on the system \"/user@host:\"."
   (let ((case-fold-search nil)
        ;; otherwise org confuses "TODO" as a kw and "Todo" as a word
        (entries (or org-refile-targets '((nil . (:level . 1)))))
-       targets tgs txt re files desc descre fast-path-p level pos0)
+       targets tgs txt re files desc descre fast-path-p level pos0)
     (message "Getting targets...")
     (with-current-buffer (or default-buffer (current-buffer))
-      (while (setq entry (pop entries))
+      (dolist (entry entries)
        (setq files (car entry) desc (cdr entry))
        (setq fast-path-p nil)
        (cond
@@ -11352,7 +11360,7 @@ on the system \"/user@host:\"."
                                              (cdr desc)))
                               "\\}[ \t]")))
         (t (error "Bad refiling target description %s" desc)))
-       (while (setq f (pop files))
+       (dolist (f files)
          (with-current-buffer
              (if (bufferp f) f (org-get-agenda-file-buffer f))
            (or
@@ -11380,7 +11388,7 @@ on the system \"/user@host:\"."
                         (setq level (org-reduced-level
                                      (- (match-end 1) (match-beginning 1)))
                               txt (org-link-display-format (match-string 4))
-                              txt (replace-regexp-in-string "\\( *\[[0-9]+/?[0-9]*%?\]\\)+$" "" txt)
+                              txt (replace-regexp-in-string "\\( *[[0-9]+/?[0-9]*%?]\\)+$" "" txt)
                               re (format org-complex-heading-regexp-format
                                          (regexp-quote (match-string 4))))
                         (when org-refile-use-outline-path
@@ -11557,7 +11565,7 @@ go to the location where the last refiling operation has put the subtree.
 With a numeric prefix argument of `2', refile to the running clock.
 
 With a numeric prefix argument of `3', emulate `org-refile-keep'
-being set to `t' and copy to the target location, don't move it.
+being set to t and copy to the target location, don't move it.
 Beware that keeping refiled entries may result in duplicated ID
 properties.
 
@@ -12076,7 +12084,7 @@ This is a list of abbreviation keys and values.  The value gets inserted
 if you type `<' followed by the key and then press the completion key,
 usually `M-TAB'.  %file will be replaced by a file name after prompting
 for the file using completion.  The cursor will be placed at the position
-of the `?` in the template.
+of the `?' in the template.
 There are two templates for each key, the first uses the original Org syntax,
 the second uses Emacs Muse-like syntax tags.  These Muse-like tags become
 the default when the /org-mtags.el/ module has been loaded.  See also the
@@ -12213,13 +12221,13 @@ With a triple \\[universal-argument] prefix, circumvent any state blocking.
 With a numeric prefix arg of 0, inhibit note taking for the change.
 
 For calling through lisp, arg is also interpreted in the following way:
-'none             -> empty state
-\"\"(empty string)  -> switch to empty state
-'done             -> switch to DONE
-'nextset          -> switch to the next set of keywords
-'previousset      -> switch to the previous set of keywords
-\"WAITING\"         -> switch to the specified keyword, but only if it
-                     really is a member of `org-todo-keywords'."
+`none'             -> empty state
+\"\" (empty string)  -> switch to empty state
+`done'             -> switch to DONE
+`nextset'          -> switch to the next set of keywords
+`previousset'      -> switch to the previous set of keywords
+\"WAITING\"          -> switch to the specified keyword, but only if it
+                      really is a member of `org-todo-keywords'."
   (interactive "P")
   (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
       (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
@@ -12678,7 +12686,8 @@ statistics everywhere."
                (outline-next-heading)))
            (setq new
                  (if is-percent
-                     (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
+                     (format "[%d%%]" (floor (* 100.0 cnt-done)
+                                             (max 1 cnt-all)))
                    (format "[%d/%d]" cnt-done cnt-all))
                  ndel (- (match-end 0) checkbox-beg))
            ;; handle overlays when updating cookie from column view
@@ -12733,20 +12742,19 @@ This hook runs even if there is no statistics cookie present, in which case
 
 (defun org-local-logging (value)
   "Get logging settings from a property VALUE."
-  (let* (words w a)
-    ;; directly set the variables, they are already local.
-    (setq org-log-done nil
-         org-log-repeat nil
-         org-todo-log-states nil)
-    (setq words (org-split-string value))
-    (while (setq w (pop words))
+  ;; Directly set the variables, they are already local.
+  (setq org-log-done nil
+        org-log-repeat nil
+        org-todo-log-states nil)
+  (dolist (w (org-split-string value))
+    (let* (a)
       (cond
        ((setq a (assoc w org-startup-options))
-       (and (member (nth 1 a) '(org-log-done org-log-repeat))
-            (set (nth 1 a) (nth 2 a))))
+        (and (member (nth 1 a) '(org-log-done org-log-repeat))
+             (set (nth 1 a) (nth 2 a))))
        ((setq a (org-extract-log-state-settings w))
-       (and (member (car a) org-todo-keywords-1)
-            (push a org-todo-log-states)))))))
+        (and (member (car a) org-todo-keywords-1)
+             (push a org-todo-log-states)))))))
 
 (defun org-get-todo-sequence-head (kwd)
   "Return the head of the TODO sequence to which KWD belongs.
@@ -12776,7 +12784,7 @@ Returns the new TODO keyword, or nil if no state change should occur."
         (expert nil)
         (fwidth (+ maxlen 3 1 3))
         (ncol (/ (- (window-width) 4) fwidth))
-        tg cnt c tbl
+        tg cnt c tbl
         groups ingroup)
     (save-excursion
       (save-window-excursion
@@ -12786,7 +12794,7 @@ Returns the new TODO keyword, or nil if no state change should occur."
        (erase-buffer)
        (org-set-local 'org-done-keywords done-keywords)
        (setq tbl fulltable cnt 0)
-       (while (setq e (pop tbl))
+       (dolist (e tbl)
          (cond
           ((equal e '(:startgroup))
            (push '() groups) (setq ingroup t)
@@ -14120,7 +14128,7 @@ See also `org-scan-tags'.
        (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\(\\(?:[[:alnum:]_]+\\(?:\\\\-\\)*\\)+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@#%]+\\)"))
        minus tag mm
        tagsmatch todomatch tagsmatcher todomatcher kwd matcher
-       orterms term orlist re-p str-p level-p level-op time-p
+       orterms orlist re-p str-p level-p level-op time-p
        prop-p pn pv po gv rest (start 0) (ss 0))
     ;; Expand group tags
     (setq match (org-tags-expand match))
@@ -14149,7 +14157,7 @@ See also `org-scan-tags'.
     (if (or (not tagsmatch) (not (string-match "\\S-" tagsmatch)))
        (setq tagsmatcher t)
       (setq orterms (org-split-string tagsmatch "|") orlist nil)
-      (while (setq term (pop orterms))
+      (dolist (term orterms)
        (while (and (equal (substring term -1) "\\") orterms)
          (setq term (concat term "|" (pop orterms)))) ; repair bad split
        (while (string-match re term)
@@ -14210,7 +14218,7 @@ See also `org-scan-tags'.
     (if (or (not todomatch) (not (string-match "\\S-" todomatch)))
        (setq todomatcher t)
       (setq orterms (org-split-string todomatch "|") orlist nil)
-      (while (setq term (pop orterms))
+      (dolist (term orterms)
        (while (string-match re term)
          (setq minus (and (match-end 1)
                           (equal (match-string 1 term) "-"))
@@ -14279,7 +14287,8 @@ When DOWNCASE is non-nil, expand downcased TAGS."
                    (with-syntax-table stable
                      (string-match
                       (concat "\\(?1:[+-]?\\)\\(?2:\\<"
-                              (regexp-opt tml) "\\>\\)") rtnmatch)))
+                              (regexp-opt tml) "\\>\\)")
+                       rtnmatch)))
          (let* ((dir (match-string 1 rtnmatch))
                 (tag (match-string 2 rtnmatch))
                 (tag (if downcased (downcase tag) tag)))
@@ -14415,7 +14424,8 @@ ignore inherited ones."
          (reverse (delete-dups
                    (reverse (append
                              (org-remove-uninherited-tags
-                              org-file-tags) tags)))))))))
+                              org-file-tags)
+                              tags)))))))))
 
 (defun org-add-prop-inherited (s)
   (add-text-properties 0 (length s) '(inherited t) s)
@@ -14747,7 +14757,7 @@ Returns the new tags string, or nil to not change the current settings."
         (ncol (/ (- (window-width) 4) fwidth))
         (i-face 'org-done)
         (c-face 'org-todo)
-        tg cnt c char c1 c2 ntable tbl rtn
+        tg cnt c char c1 c2 ntable tbl rtn
         ov-start ov-end ov-prefix
         (exit-after-next org-fast-tag-selection-single-key)
         (done-keywords org-done-keywords)
@@ -14782,7 +14792,7 @@ Returns the new tags string, or nil to not change the current settings."
       (org-fast-tag-show-exit exit-after-next)
       (org-set-current-tags-overlay current ov-prefix)
       (setq tbl fulltable char ?a cnt 0)
-      (while (setq e (pop tbl))
+      (dolist (e tbl)
        (cond
         ((equal (car e) :startgroup)
          (push '() groups) (setq ingroup t)
@@ -15058,7 +15068,7 @@ a *different* entry, you cannot use these techniques."
          (if (not scope)
              (progn
                (org-agenda-prepare-buffers
-                (list (buffer-file-name (current-buffer))))
+                (and buffer-file-name (list buffer-file-name)))
                (setq res (org-scan-tags func matcher todo-only start-level)))
            ;; Get the right scope
            (cond
@@ -15070,11 +15080,11 @@ a *different* entry, you cannot use these techniques."
              (setq scope (org-agenda-files t))
              (setq scope (org-add-archive-files scope)))
             ((eq scope 'file)
-             (setq scope (list (buffer-file-name))))
+             (setq scope (and buffer-file-name (list buffer-file-name))))
             ((eq scope 'file-with-archives)
              (setq scope (org-add-archive-files (list (buffer-file-name))))))
            (org-agenda-prepare-buffers scope)
-           (while (setq file (pop scope))
+           (dolist (file scope)
              (with-current-buffer (org-find-base-buffer-visiting file)
                (save-excursion
                  (save-restriction
@@ -15540,7 +15550,7 @@ and the new value.")
 
 (defun org-entry-put (pom property value)
   "Set PROPERTY to VALUE for entry at point-or-marker POM.
-If the value is `nil', it is converted to the empty string.
+If the value is nil, it is converted to the empty string.
 If it is not a string, an error is raised."
   (cond ((null value) (setq value ""))
        ((not (stringp value))
@@ -16031,7 +16041,7 @@ only headings."
          (widen)
          (setq limit (point-max))
          (goto-char (point-min))
-         (while (setq heading (pop path))
+         (dolist (heading path)
            (setq re (format org-complex-heading-regexp-format
                             (regexp-quote heading)))
            (setq cnt 0 pos (point))
@@ -16076,7 +16086,7 @@ When the target headline is found, return a marker to this location."
                                nil "\\`[^.#].*\\.org\\'"))
         file visiting m buffer)
     (catch 'found
-      (while (setq file (pop files))
+      (dolist (file files)
         (message "trying %s" file)
         (setq visiting (org-find-base-buffer-visiting file))
         (setq buffer (or visiting (find-file-noselect file)))
@@ -16344,7 +16354,7 @@ While prompting, a calendar is popped up - you can also select the
 date with the mouse (button 1).  The calendar shows a period of three
 months.  To scroll it to other months, use the keys `>' and `<'.
 If you don't like the calendar, turn it off with
-       \(setq org-read-date-popup-calendar nil)
+       (setq org-read-date-popup-calendar nil)
 
 With optional argument TO-TIME, the date will immediately be converted
 to an internal time.
@@ -16875,7 +16885,7 @@ Don't touch the rest."
 (defun org-time-stamp-to-now (timestamp-string &optional seconds)
   "Difference between TIMESTAMP-STRING and now in days.
 If SECONDS is non-nil, return the difference in seconds."
-  (let ((fdiff (if seconds 'org-float-time 'time-to-days)))
+  (let ((fdiff (if seconds 'float-time 'time-to-days)))
     (- (funcall fdiff (org-time-string-to-time timestamp-string))
        (funcall fdiff (current-time)))))
 
@@ -16954,12 +16964,12 @@ Allowed values for TYPE are:
 
 When TYPE is nil, fall back on returning a regexp that matches
 both scheduled and deadline timestamps."
-  (cond ((eq type 'all) "\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\(?: +[^]+0-9>\r\n -]+\\)?\\(?: +[0-9]\\{1,2\\}:[0-9]\\{2\\}\\)?\\)")
+  (cond ((eq type 'all) "\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\(?: +[^]+0-9>\r\n -]+\\)?\\(?: +[0-9]\\{1,2\\}:[0-9]\\{2\\}\\)?\\)")
        ((eq type 'active) org-ts-regexp)
-       ((eq type 'inactive) "\\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)\\]")
+       ((eq type 'inactive) "\\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)\\]")
        ((eq type 'scheduled) (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>"))
        ((eq type 'deadline) (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
-       ((eq type 'closed) (concat org-closed-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)\\]"))
+       ((eq type 'closed) (concat org-closed-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)\\]"))
        ((eq type 'scheduled-or-deadline)
         (concat "\\<\\(?:" org-deadline-string "\\|" org-scheduled-string "\\) *<\\([^>]+\\)>"))))
 
@@ -17030,8 +17040,8 @@ days in order to avoid rounding problems."
          (match-end (match-end 0))
          (time1 (org-time-string-to-time ts1))
          (time2 (org-time-string-to-time ts2))
-         (t1 (org-float-time time1))
-         (t2 (org-float-time time2))
+         (t1 (float-time time1))
+         (t2 (float-time time2))
          (diff (abs (- t2 t1)))
          (negative (< (- t2 t1) 0))
          ;; (ys (floor (* 365 24 60 60)))
@@ -17091,12 +17101,12 @@ days in order to avoid rounding problems."
     (error (error "Bad timestamp `%s'%s\nError was: %s"
                  s (if (not (and buffer pos))
                        ""
-                     (format " at %d in buffer `%s'" pos buffer))
+                     (format-message " at %d in buffer `%s'" pos buffer))
                  (cdr errdata)))))
 
 (defun org-time-string-to-seconds (s)
   "Convert a timestamp string to a number of seconds."
-  (org-float-time (org-time-string-to-time s)))
+  (float-time (org-time-string-to-time s)))
 
 (defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos)
   "Convert a time stamp to an absolute day number.
@@ -17119,7 +17129,7 @@ The variable `date' is bound by the calendar when this is called."
         (error (error "Bad timestamp `%s'%s\nError was: %s"
                       s (if (not (and buffer pos))
                             ""
-                          (format " at %d in buffer `%s'" pos buffer))
+                          (format-message " at %d in buffer `%s'" pos buffer))
                       (cdr errdata))))))))
 
 (defun org-days-to-iso-week (days)
@@ -17448,8 +17458,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"."
                         (+ (if (eq org-ts-what 'hour) n 0)   (nth 2 time0))
                         (+ (if (eq org-ts-what 'day) n 0)    (nth 3 time0))
                         (+ (if (eq org-ts-what 'month) n 0)  (nth 4 time0))
-                        (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))
-                        (nthcdr 6 time0)))
+                        (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))))
       (when (and (member org-ts-what '(hour minute))
                 extra
                 (string-match "-\\([012][0-9]\\):\\([0-5][0-9]\\)" extra))
@@ -17748,7 +17757,7 @@ If no number is found, the return value is 0."
 (defcustom org-image-actual-width t
   "Should we use the actual width of images when inlining them?
 
-When set to `t', always use the image width.
+When set to t, always use the image width.
 
 When set to a number, use imagemagick (when available) to set
 the image's width to this value.
@@ -17775,7 +17784,7 @@ This requires Emacs >= 24.1, build with imagemagick support."
 
 (defcustom org-agenda-inhibit-startup nil
   "Inhibit startup when preparing agenda buffers.
-When this variable is `t', the initialization of the Org agenda
+When this variable is t, the initialization of the Org agenda
 buffers is inhibited: e.g. the visibility state is not set, the
 tables are not re-aligned, etc."
   :type 'boolean
@@ -17901,7 +17910,7 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
           ((eq predicate 'files)
            (lambda (b) (with-current-buffer b (derived-mode-p 'org-mode))))
           ((eq predicate 'export)
-           (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
+           (lambda (b) (string-match "\\*Org .*Export" (buffer-name b))))
           ((eq predicate 'agenda)
            (lambda (b)
              (with-current-buffer b
@@ -17910,7 +17919,7 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
                     (member (file-truename bfn) agenda-files)))))
           (t (lambda (b) (with-current-buffer b
                            (or (derived-mode-p 'org-mode)
-                               (string-match "\*Org .*Export"
+                               (string-match "\\*Org .*Export"
                                              (buffer-name b)))))))))
     (delq nil
          (mapcar
@@ -18034,7 +18043,7 @@ If the current buffer does not, find the first agenda file."
         file)
     (unless files (user-error "No agenda files"))
     (catch 'exit
-      (while (setq file (pop files))
+      (dolist (file files)
        (if (equal (file-truename file) tcf)
            (when (car files)
              (find-file (car files))
@@ -18120,8 +18129,8 @@ it to the list of buffers which might be released later."
   "Release all buffers in list, asking the user for confirmation when needed.
 When a buffer is unmodified, it is just killed.  When modified, it is saved
 \(if the user agrees) and then killed."
-  (let (buf file)
-    (while (setq buf (pop blist))
+  (let (file)
+    (dolist (buf blist)
       (setq file (buffer-file-name buf))
       (when (and (buffer-modified-p buf)
                 file
@@ -18143,7 +18152,7 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
          org-tag-groups-alist-for-agenda nil)
     (save-excursion
       (save-restriction
-       (while (setq file (pop files))
+       (dolist (file files)
          (catch 'nextfile
            (if (bufferp file)
                (set-buffer file)
@@ -18423,11 +18432,11 @@ Some of the options can be changed using the variable
         (optnew org-format-latex-options)
         (matchers (plist-get opt :matchers))
         (re-list org-latex-regexps)
-        (cnt 0) txt hash link beg end re checkdir
+        (cnt 0) txt hash link beg end re checkdir
         string
         m n block-type block linkfile movefile ov)
     ;; Check the different regular expressions
-    (while (setq e (pop re-list))
+    (dolist (e re-list)
       (setq m (car e) re (nth 1 e) n (nth 2 e) block-type (nth 3 e)
            block (if block-type "\n\n" ""))
       (when (member m matchers)
@@ -19051,7 +19060,7 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-i"       'org-cycle)
 (org-defkey org-mode-map [(tab)]      'org-cycle)
 (org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived)
-(org-defkey org-mode-map "\M-\t" 'pcomplete)
+(org-defkey org-mode-map "\M-\t" #'pcomplete)
 ;; The following line is necessary under Suse GNU/Linux
 (unless (featurep 'xemacs)
   (org-defkey org-mode-map [S-iso-lefttab]  'org-shifttab))
@@ -19118,7 +19127,7 @@ BEG and END default to the buffer boundaries."
   (org-defkey org-mode-map [?\C-c (right)] 'org-shiftright)
   (org-defkey org-mode-map [?\C-c ?\C-x (right)] 'org-shiftcontrolright)
   (org-defkey org-mode-map [?\C-c ?\C-x (left)] 'org-shiftcontrolleft)
-  (org-defkey org-mode-map [?\e (tab)] 'pcomplete)
+  (org-defkey org-mode-map [?\e (tab)] #'pcomplete)
   (org-defkey org-mode-map [?\e (shift return)] 'org-insert-todo-heading)
   (org-defkey org-mode-map [?\e (shift left)]   'org-shiftmetaleft)
   (org-defkey org-mode-map [?\e (shift right)]  'org-shiftmetaright)
@@ -20435,7 +20444,7 @@ This command does many different things, depending on context:
           ;; a `table.el' type, just give up.  At a table row or
           ;; cell, maybe recalculate line but always align table.
           (if (eq (org-element-property :type context) 'table.el)
-              (message "Use C-c ' to edit table.el tables")
+              (message "%s" "Use C-c ' to edit table.el tables")
             (let ((org-enable-table-editor t))
               (if (or (eq type 'table)
                       ;; Check if point is at a TBLFM line.
@@ -20781,8 +20790,8 @@ number of stars to add."
                   (insert
                    (org-list-to-subtree
                     (org-list-parse-list t)
-                    '(:istart (concat stars add-stars (funcall get-stars depth))
-                              :icount (concat stars add-stars (funcall get-stars depth)))))))
+                    `(:istart (concat ',stars ',add-stars (funcall get-stars depth))
+                       :icount (concat ',stars ',add-stars (funcall get-stars depth)))))))
               (setq toggled t))
             (forward-line))))
        ;; Case 3. Started at normal text: make every line an heading,
@@ -20804,11 +20813,11 @@ number of stars to add."
               (forward-line)))))))
     (unless toggled (message "Cannot toggle heading from here"))))
 
-(defun org-meta-return (&optional arg)
+(defun org-meta-return (&optional _arg)
   "Insert a new heading or wrap a region in a table.
 Calls `org-insert-heading' or `org-table-wrap-region', depending
 on context.  See the individual commands for more information."
-  (interactive "P")
+  (interactive)
   (org-check-before-invisible-edit 'insert)
   (or (run-hook-with-args-until-success 'org-metareturn-hook)
       (let* ((element (org-element-at-point))
@@ -21106,6 +21115,7 @@ output buffer into your mail program, as it gives us important
 information about your Org-mode version and configuration."
   (interactive)
   (require 'reporter)
+  (defvar reporter-prompt-for-summary-p)
   (org-load-modules-maybe)
   (org-require-autoloaded-modules)
   (let ((reporter-prompt-for-summary-p "Bug report subject: "))
@@ -21365,11 +21375,13 @@ upon the next fontification round."
                                        'invisible 'org-link s))
        (setq s (concat (substring s 0 b)
                        (substring s (or (next-single-property-change
-                                         b 'invisible s) (length s)))))))
+                                         b 'invisible s)
+                                         (length s)))))))
     (while (setq b (text-property-any 0 (length s) 'org-cwidth t s))
       (setq s (concat (substring s 0 b)
                      (substring s (or (next-single-property-change
-                                       b 'org-cwidth s) (length s))))))
+                                       b 'org-cwidth s)
+                                       (length s))))))
     (setq l (string-width s) b -1)
     (while (setq b (text-property-any (1+ b) (length s) 'org-dwidth t s))
       (setq l (- l (get-text-property b 'org-dwidth-n s))))
@@ -21466,11 +21478,9 @@ N may optionally be the number of spaces to remove."
 
 (defun org-fill-template (template alist)
   "Find each %key of ALIST in TEMPLATE and replace it."
-  (let ((case-fold-search nil)
-       entry key value)
-    (setq alist (sort (copy-sequence alist)
-                     (lambda (a b) (< (length (car a)) (length (car b))))))
-    (while (setq entry (pop alist))
+  (let ((case-fold-search nil))
+    (dolist (entry (sort (copy-sequence alist)
+                         (lambda (a b) (< (length (car a)) (length (car b))))))
       (setq template
            (replace-regexp-in-string
             (concat "%" (regexp-quote (car entry)))
@@ -21792,23 +21802,24 @@ block from point."
        "^[ \t]*:end:.*$"
        lim-up lim-down))))
 
-(defun org-occur-in-agenda-files (regexp &optional nlines)
+(defun org-occur-in-agenda-files (regexp &optional _nlines)
   "Call `multi-occur' with buffers for all agenda files."
-  (interactive "sOrg-files matching: \np")
+  (interactive "sOrg-files matching: ")
   (let* ((files (org-agenda-files))
-        (tnames (mapcar 'file-truename files))
-        (extra org-agenda-text-search-extra-files)
-        f)
+        (tnames (mapcar #'file-truename files))
+        (extra org-agenda-text-search-extra-files))
     (when (eq (car extra) 'agenda-archives)
       (setq extra (cdr extra))
       (setq files (org-add-archive-files files)))
-    (while (setq f (pop extra))
+    (dolist (f extra)
       (unless (member (file-truename f) tnames)
-       (add-to-list 'files f 'append)
-       (add-to-list 'tnames (file-truename f) 'append)))
+        (unless (member f files) (setq files (append files (list f))))
+        (setq tnames (append tnames (list (file-truename f))))))
     (multi-occur
      (mapcar (lambda (x)
               (with-current-buffer
+                   ;; FIXME: Why not just (find-file-noselect x)?
+                   ;; Is it to avoid the "revert buffer" prompt?
                   (or (get-file-buffer x) (find-file-noselect x))
                 (widen)
                 (current-buffer)))
@@ -21858,8 +21869,8 @@ for the search purpose."
 
 For example, in this alist:
 
-\(org-uniquify-alist '((a 1) (b 2) (a 3)))
-  => '((a 1 3) (b 2))
+\(org-uniquify-alist \\='((a 1) (b 2) (a 3)))
+  => \\='((a 1 3) (b 2))
 
 merge (a 1) and (a 3) into (a 1 3).
 
@@ -21993,7 +22004,7 @@ so values can contain further %-escapes if they are define later in TABLE."
        (case-fold-search nil)
         (pchg 0)
         e re rpl)
-    (while (setq e (pop tbl))
+    (dolist (e tbl)
       (setq re (concat "%-?[0-9.]*" (substring (car e) 1)))
       (when (and (cdr e) (string-match re (cdr e)))
         (let ((sref (substring (cdr e) (match-beginning 0) (match-end 0)))
@@ -22056,7 +22067,7 @@ This works in the calendar and in the agenda, anywhere else it just
 returns the current time.
 If WITH-TIME is non-nil, returns the time of the event at point (in
 the agenda) or the current time of the day."
-  (let (date day defd tp tm hod mod)
+  (let (date day defd tp hod mod)
     (when with-time
       (setq tp (get-text-property (point) 'time))
       (when (and tp (string-match "\\([0-9][0-9]\\):\\([0-9][0-9]\\)" tp))
@@ -22587,7 +22598,7 @@ If the line is empty, insert comment at its beginning."
   (insert "# "))
 
 (defvar comment-empty-lines)           ; From newcomment.el.
-(defun org-comment-or-uncomment-region (beg end &rest ignore)
+(defun org-comment-or-uncomment-region (beg end &rest _)
   "Comment or uncomment each non-blank line in the region.
 Uncomment each non-blank line between BEG and END if it only
 contains commented lines.  Otherwise, comment them."
@@ -22650,7 +22661,7 @@ contains commented lines.  Otherwise, comment them."
   "Non-nil when TIMESTAMP has a time specified."
   (org-element-property :hour-start timestamp))
 
-(defun org-timestamp-format (timestamp format &optional end utc)
+(defun org-timestamp-format (timestamp format &optional end zone)
   "Format a TIMESTAMP element into a string.
 
 FORMAT is a format specifier to be passed to
@@ -22659,8 +22670,11 @@ FORMAT is a format specifier to be passed to
 When optional argument END is non-nil, use end of date-range or
 time-range, if possible.
 
-When optional argument UTC is non-nil, time will be expressed as
-Universal Time."
+The optional ZONE is omitted or nil for Emacs local time, t for
+Universal Time, `wall' for system wall clock time, or a string as
+in the TZ environment variable.  It can also be a list (as from
+`current-time-zone') or an integer (as from `decode-time')
+applied without consideration for daylight saving time."
   (format-time-string
    format
    (apply 'encode-time
@@ -22670,7 +22684,7 @@ Universal Time."
                  (if end '(:minute-end :hour-end :day-end :month-end :year-end)
                    '(:minute-start :hour-start :day-start :month-start
                                    :year-start)))))
-   utc))
+   zone))
 
 (defun org-timestamp-split-range (timestamp &optional end)
   "Extract a timestamp object from a date or time range.
@@ -22779,6 +22793,10 @@ this line is also exported in fixed-width font."
          (goto-char (match-end 0))
          (insert org-quote-string " ")))))))
 
+(defvar reftex-docstruct-symbol)
+(defvar reftex-cite-format)
+(defvar org--rds)
+
 (defun org-reftex-citation ()
   "Use reftex-citation to insert a citation into the buffer.
 This looks for a line like
@@ -22793,9 +22811,9 @@ into the buffer.
 Export of such citations to both LaTeX and HTML is handled by the contributed
 package ox-bibtex by Taru Karttunen."
   (interactive)
-  (let ((reftex-docstruct-symbol 'rds)
+  (let ((reftex-docstruct-symbol 'org--rds)
        (reftex-cite-format "\\cite{%l}")
-       rds bib)
+       org--rds bib)
     (save-excursion
       (save-restriction
        (widen)
@@ -22806,7 +22824,7 @@ package ox-bibtex by Taru Karttunen."
                         (re-search-backward re nil t))))
              (error "No bibliography defined in file")
            (setq bib (concat (match-string 1) ".bib")
-                 rds (list (list 'bib bib)))))))
+                 org--rds (list (list 'bib bib)))))))
     (call-interactively 'reftex-citation)))
 
 ;;;; Functions extending outline functionality
@@ -22923,20 +22941,20 @@ the cursor is already beyond the end of the headline."
 (define-key org-mode-map "\C-a" 'org-beginning-of-line)
 (define-key org-mode-map "\C-e" 'org-end-of-line)
 
-(defun org-backward-sentence (&optional arg)
+(defun org-backward-sentence (&optional _arg)
   "Go to beginning of sentence, or beginning of table field.
 This will call `backward-sentence' or `org-table-beginning-of-field',
 depending on context."
-  (interactive "P")
+  (interactive)
   (cond
    ((org-at-table-p) (call-interactively 'org-table-beginning-of-field))
    (t (call-interactively 'backward-sentence))))
 
-(defun org-forward-sentence (&optional arg)
+(defun org-forward-sentence (&optional _arg)
   "Go to end of sentence, or end of table field.
 This will call `forward-sentence' or `org-table-end-of-field',
 depending on context."
-  (interactive "P")
+  (interactive)
   (cond
    ((org-at-table-p) (call-interactively 'org-table-end-of-field))
    (t (call-interactively 'forward-sentence))))
@@ -22944,9 +22962,9 @@ depending on context."
 (define-key org-mode-map "\M-a" 'org-backward-sentence)
 (define-key org-mode-map "\M-e" 'org-forward-sentence)
 
-(defun org-kill-line (&optional arg)
+(defun org-kill-line (&optional _arg)
   "Kill line, to tags or end of line."
-  (interactive "P")
+  (interactive)
   (cond
    ((or (not org-special-ctrl-k)
        (bolp)
@@ -22988,7 +23006,7 @@ no special treatment.  In particular, a simple \\[universal-argument] prefix \
 will just
 plainly yank the text as it is.
 
-\[1] The test checks if the first non-white line is a heading
+[1] The test checks if the first non-white line is a heading
     and if there are no other headings with fewer stars."
   (interactive "P")
   (org-yank-generic 'yank arg))