(if (characterp (cdr tg))
(format "(%s)" (char-to-string (cdr tg))) "")))))
org-tag-alist)))
- (let (e tgs g)
- (while (setq e (pop tags))
+ (let (tgs g)
+ (dolist (e tags)
(cond
((equal e "{")
(progn (push '(:startgroup) tgs)
((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)
(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)))
((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")
(org-table-set-constants))
((equal key "STARTUP")
(let ((opts (org-split-string value splitre))
- l 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))
(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)
(defun org-assign-fast-keys (alist)
"Assign fast keys to a keyword-key alist.
Respect keys that are already there."
- (let (new e (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)
(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))
(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)
(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)
(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)))
(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))
(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
(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
(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)
;; 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))
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)))
((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'.")
(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 f 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
(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
(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.
(expert nil)
(fwidth (+ maxlen 3 1 3))
(ncol (/ (- (window-width) 4) fwidth))
- tg cnt e c tbl
+ tg cnt c tbl
groups ingroup)
(save-excursion
(save-window-excursion
(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)
(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))
(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)
(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) "-"))
(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)))
(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)
(ncol (/ (- (window-width) 4) fwidth))
(i-face 'org-done)
(c-face 'org-todo)
- tg cnt e 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)
(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)
((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
(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))
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)))
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))
"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
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)
(optnew org-format-latex-options)
(matchers (plist-get opt :matchers))
(re-list org-latex-regexps)
- (cnt 0) txt hash link beg end re e 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)
(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))
(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)
(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,
(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))
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: "))
'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))))
(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)))
"^[ \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)))
(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)))
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))
(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."
(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
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)
(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
(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))))
(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)