org-mode/lisp
Stefan Monnier 129c33dddf * lisp/org-agenda.el: Use lexical-binding
- Removed the global (defvar date) and (defvar entry) so as not to
  conflict with function arguments of that name.  Instead I added such
  `defvar`s in the body of each of the functions where it
  seemed needed.
- I added some FIXMEs for some issues I found along the way.
- Added an `org-dlet` macro, just like I had done for `calendar-dlet`,
  but I also use `defvar` "manually" at some places, when splitting an
  existing `let` into a mix of `let`s and `dlet`s seemed too much trouble.
- Removed uses of `org-let and `org-let2` not only because I consider
  them offensive to my sense of aesthetics but also because they're
  basically incompatible with lexical scoping.
  I replaced them with uses of `cl-progv` which are a bit more verbose.
  Maybe we should define some `org-progv` macro on top of `cl-progv` to
  make the code less verbose, but I didn't do that because I like the
  fact that the current code makes uses of `eval` a bit more obvious
  (since these behave differently with lexical scoping than with
  lexical binding, it seemed worthwhile).
- Removed the use of `eval` in `org-store-agenda-views` which was only
  placed there in order to use a macro before it's defined (it would
  have been simpler/cleaner to just move that functions *after* the
  macro, but with the new code the problem doesn't occur any more anyway).
- Replaced a few `(lambda...) with actual closures.

Detailed changes follow:

(date, entry): Don't declare as being globally dynbound.
(org-agenda-format-date-aligned): Remove unused var `weekyear`.
(org-agenda-mode): `run-mode-hooks` is always available nowadays.
(org-agenda-undo): Remove unused var `last-undo-buffer`.
(org-agenda): Rename arg to `keys` and then dyn-bind it as `org-keys`.
Remove unused vars `buf` and `key`.
(org-agenda): Use `pcase` and `cl-progv` instead of `org-let`.
(org-let, org-let2): Mark as obsolete.
(org-agenda-run-series): Use `cl-progv` instead of `org-let` and `org-let2`.
(org-agenda-run-series): New function.
(org--batch-agenda): New function extracted from `org-batch-agenda`.
(org-batch-agenda): Use it.
(org--batch-agenda-csv): New function extracted from `org-batch-agenda-csv`.
(org-batch-agenda-csv): Use it.
(org--batch-store-agenda-views): New function, extracted from
`org-batch-store-agenda-views`.
(org-store-agenda-views, org-batch-store-agenda-views): Use it.
(org--batch-store-agenda-views): Use `cl-progv` instead of
`org-eval-in-environment`.
(org-agenda-write): Use `cl-progv` instead of `org-let`.
Use `with-current-buffer`.
(org-agenda-filter-any): Use `cl-some` instead of `eval`.
(org-agenda-list): Remove unused var `e`.
(org-search-view): η-reduce.
(crm-separator): Declare var.
(org-agenda-skip-if): Remove unused var `beg`.
(org-agenda-list-stuck-projects): Use a closure rather than `(lambda..).
(diary-modify-entry-list-string-function, diary-file-name-prefix)
(diary-display-function): Declare vars.
(org-diary): Declare `date` and `entry` as dynbound.
(org-agenda-get-day-entries): Use `org-dlet`.
(org-agenda-get-timestamps, org-agenda-get-progress)
(org-agenda-get-deadlines, org-agenda-get-scheduled, org-agenda-get-blocks):
Declare `date` as dynbound.
(org-agenda-get-sexps, org-class): Declare `date` and `entry` as dynbound.
(org-agenda-format-item): Declare the vars mentioned in
`org-compile-prefix-format` as dyn-bound.
Also binding `extra`, suggested by Kyle Meyer <kyle@kyleam.com>.
(org-compile-prefix-format): Remove unused var `e`.
Use `member` rather than or+equal.
(org-set-sorting-strategy): Minor simplification.
(org-entries-lessp): Use `org-dlet`.
(org-agenda-redo): Declare var `org-agenda-tag-filter-while-redo`.
(org-agenda-redo): Use `cl-progv` rather than `org-let`.
(org-agenda-filter): Remove unused var `rpl-fn`.
Use `org-pushnew-to-end` to replace `add-to-list` on lexical var.
(org-agenda-filter-by-tag): Remove unused var `n`.
(org-agenda-filter-apply): Use `org-dlet`.
(org-agenda-compute-starting-span): Remove unused var `dg`.
(org-agenda-forward-block): Remove unused var `pos`.
(org-archive-from-agenda): Declare var.
(org-agenda-refile): Remove unused var `pos`.
(org-agenda-headline-snapshot-before-repeat): Declare var.
(org-agenda-todo): Remove redundant use of `bound-and-true-p`.
(org-agenda-add-note): Remove unused var `hdmarker` and unused `arg`.
(org-agenda-change-all-lines): Remove unused var `pl`.
(org-agenda-priority): Remove unused var `marker`.
(org-agenda-set-effort): Remove unused var `newhead`.
(org-agenda-schedule): Remove unused var `type`.
(org-agenda-clock-cancel): Remove unused `arg`.
(org-agenda-execute-calendar-command): Use `org-dlet`.
(org-agenda-bulk-action): Use closures instead of `(lambda ...).
(org-agenda-show-the-flagging-note): Remove unused vars `heading` and
`newhead`.
(org-agenda-remove-flag): Avoid `setq`.

* testing/org-test.el (org--compile-when): New macro.
(org-test-jump): Use it so compilation doesn't fail or generate broken
code when `jump` is not available.

* testing/lisp/test-org-src.el:
* testing/lisp/test-org-attach.el:
* testing/lisp/test-org-agenda.el:
* testing/lisp/test-ob-java.el: Pass explicit filename to `require`
so as not to rely on ".../testing" being in `load-path` during compilation.

* lisp/org-num.el: Require` org`.

* lisp/org-macs.el (org-eval-in-environment): Declare obsolete.
(org-dlet, org-pushnew-to-end): New macros.

* doc/Makefile (org.texi, orgguide.texi, %_letter.tex): Simplify quoting.

* contrib/lisp/ob-sclang.el: Don't crash compilation when `sclang`
is not available.

* contrib/lisp/ob-clojure-literate.el: Don't crash compilation when `cider`
is not available.

* contrib/lisp/ob-arduino.el: Don't crash compilation when `arduino-mode`
is not available.

* .gitignore: Add files generated during `make packages/org`.
2021-03-09 22:56:33 -05:00
..
Makefile Move link-related core functions out of "org.el" 2019-03-10 18:00:27 +01:00
ob-C.el ob-C.el: Fix missing C, C++ declaration 2021-01-14 21:20:00 +01:00
ob-J.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-R.el Merge branch 'km/from-emacs-master' 2021-02-14 18:06:23 -05:00
ob-abc.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-asymptote.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-awk.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-calc.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-clojure.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-comint.el Backport commit f8dbefbaa from Emacs 2021-02-14 17:38:07 -05:00
ob-coq.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-core.el Merge branch 'km/from-emacs-master' 2021-02-14 18:06:23 -05:00
ob-css.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-ditaa.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-dot.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-ebnf.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-emacs-lisp.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-eshell.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-eval.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-exp.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-forth.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-fortran.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-gnuplot.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-groovy.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-haskell.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-hledger.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-io.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-java.el ob-java: Fix previous commit 2021-02-14 15:42:18 -05:00
ob-js.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-latex.el Shorten remaining over-wide docstrings 2021-02-23 23:35:57 -05:00
ob-ledger.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-lilypond.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-lisp.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-lob.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-lua.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-makefile.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-matlab.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-maxima.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-mscgen.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-ocaml.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-octave.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-org.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-perl.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-picolisp.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-plantuml.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-processing.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-python.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-ref.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-ruby.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-sass.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-scheme.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-screen.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ob-sed.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-shell.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-shen.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-sql.el Reduce code duplication in ob-sqlite.el and ob-sql.el 2021-03-09 00:43:43 -05:00
ob-sqlite.el Reduce code duplication in ob-sqlite.el and ob-sql.el 2021-03-09 00:43:43 -05:00
ob-stan.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-table.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob-tangle.el Backport commit f8dbefbaa from Emacs 2021-02-14 17:38:07 -05:00
ob-vala.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ob.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-bbdb.el Backport commit dd662fc97 from Emacs 2021-02-14 17:38:07 -05:00
ol-bibtex.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-docview.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-eshell.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-eww.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-gnus.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-info.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-irc.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-mhe.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-rmail.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ol-w3m.el Backport commit ce35760b1 from Emacs 2021-02-14 17:38:07 -05:00
ol.el Merge branch 'km/from-emacs-master' 2021-02-14 18:06:23 -05:00
org-agenda.el * lisp/org-agenda.el: Use lexical-binding 2021-03-09 22:56:33 -05:00
org-archive.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-attach-git.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-attach.el Merge branch 'km/from-emacs-master' 2021-02-14 18:06:23 -05:00
org-capture.el Merge branch 'maint' 2021-02-02 00:26:43 -05:00
org-clock.el org-clock: Replace org-clocking-buffer with org-clock-is-active 2021-03-03 22:50:04 -05:00
org-colview.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-compat.el Merge branch 'maint' 2021-02-03 01:27:15 -05:00
org-crypt.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-ctags.el Backport commit 64d97212f from Emacs 2021-02-14 17:38:07 -05:00
org-datetree.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-duration.el duration: Avoid recursive load error 2021-01-04 00:30:00 -05:00
org-element.el Merge branch 'km/from-emacs-master' 2021-02-28 17:24:54 -05:00
org-entities.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-faces.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
org-feed.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-footnote.el footnote: Silence byte-compiler under 'make single' 2021-02-03 23:07:33 -05:00
org-goto.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-habit.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-id.el Avoid alist-get for compatibility with Emacs 24 2021-02-07 20:05:51 -05:00
org-indent.el Backport commit 5ab5c3898 from Emacs 2021-02-14 17:38:07 -05:00
org-inlinetask.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-install.el Use lexical-binding cookie in some trivial files 2021-01-24 22:36:30 -05:00
org-keys.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-lint.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
org-list.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
org-macro.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-macs.el * lisp/org-agenda.el: Use lexical-binding 2021-03-09 22:56:33 -05:00
org-mobile.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-mouse.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-num.el * lisp/org-agenda.el: Use lexical-binding 2021-03-09 22:56:33 -05:00
org-pcomplete.el Backport commit f8dbefbaa from Emacs 2021-02-14 17:38:07 -05:00
org-plot.el Shorten remaining over-wide docstrings 2021-02-23 23:35:57 -05:00
org-protocol.el Backport commit 5ab5c3898 from Emacs 2021-02-14 17:38:07 -05:00
org-refile.el Merge branch 'km/from-emacs-master' 2021-02-14 18:06:23 -05:00
org-src.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-table.el Merge branch 'km/from-emacs-master' 2021-02-14 18:06:23 -05:00
org-tempo.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org-timer.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
org.el org.el: Specify minimum Emacs version in Package-Requires header 2021-03-09 22:16:15 -05:00
ox-ascii.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ox-beamer.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ox-html.el lisp/ox-html.el: make html meta tags customizable 2021-01-20 22:27:02 -05:00
ox-icalendar.el ox-calendar: Require Org Agenda 2021-02-20 10:41:02 +01:00
ox-latex.el Merge branch 'maint' 2021-01-24 23:12:33 -05:00
ox-man.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ox-md.el ox-md.el: Preserve radio target hyperlink 2021-01-22 00:05:47 -05:00
ox-odt.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00
ox-org.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ox-publish.el Update copyright year to 2021 2021-01-01 14:59:01 -05:00
ox-texinfo.el Backport commit 18e1455c8 from Emacs 2021-03-09 22:12:02 -05:00
ox.el Merge branch 'maint' 2021-01-01 15:02:10 -05:00