From 7809484fe19beb737ff8dbd35007b737525ed357 Mon Sep 17 00:00:00 2001 From: rjhwelsh Date: Thu, 17 May 2018 15:36:41 +1200 Subject: [PATCH 01/40] ob-plantupml: Added LaTeX output support * lisp/ob-plantuml.el (org-babel-execute:plantuml): Added LaTeX output support. TINYCHANGE --- lisp/ob-plantuml.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el index 9a9313e7b..dd1a65f76 100644 --- a/lisp/ob-plantuml.el +++ b/lisp/ob-plantuml.el @@ -93,6 +93,8 @@ This function is called by `org-babel-execute-src-block'." " -teps" "") (if (string= (file-name-extension out-file) "pdf") " -tpdf" "") + (if (string= (file-name-extension out-file) "tex") + " -tlatex" "") (if (string= (file-name-extension out-file) "vdx") " -tvdx" "") (if (string= (file-name-extension out-file) "xmi") From 537748b7b7dbcac5ca7a0a601a542dc31be3040b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 30 May 2018 13:17:35 +0200 Subject: [PATCH 02/40] ORG-NEWS: Update --- etc/ORG-NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 811e98147..5ba98ca97 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -10,6 +10,12 @@ See the end of the file for license conditions. Please send Org bug reports to mailto:emacs-orgmode@gnu.org. +* Version 9.3 + +** Babel + +*** Add LaTeX output support in PlantUML + * Version 9.2 ** Incompatible changes *** Removal of OrgStruct mode mode and radio lists From 1b81d6e07bc5ac78fe68674c0269c7dacd6b543f Mon Sep 17 00:00:00 2001 From: stardiviner Date: Thu, 31 May 2018 23:07:47 +0200 Subject: [PATCH 03/40] ob-eshell.el: Add Eshell support for Babel * lisp/ob-eshell.el (org-babel-execute:eshell): Execute Eshell code in Babel. (org-babel-prep-session:eshell): (ob-eshell-session-live-p): (org-babel-eshell-initiate-session): (org-babel-variable-assignments:eshell): (org-babel-load-session:eshell): * testing/test-ob-eshell.el: Write test for ob-eshell. * doc/org-manual.org (Languages): Add Babel language eshell identity. --- doc/org-manual.org | 46 +++++++-------- lisp/ob-eshell.el | 105 +++++++++++++++++++++++++++++++++ testing/lisp/test-ob-eshell.el | 73 +++++++++++++++++++++++ 3 files changed, 201 insertions(+), 23 deletions(-) create mode 100644 lisp/ob-eshell.el create mode 100644 testing/lisp/test-ob-eshell.el diff --git a/doc/org-manual.org b/doc/org-manual.org index 27131c805..535aa9d7f 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -17600,29 +17600,29 @@ code block header arguments: Code blocks in the following languages are supported. #+attr_texinfo: :columns 0.20 0.35 0.20 0.20 -| Language | Identifier | Language | Identifier | -|------------+---------------+---------------+--------------| -| Asymptote | =asymptote= | Lua | =lua= | -| Awk | =awk= | MATLAB | =matlab= | -| C | =C= | Mscgen | =mscgen= | -| C++ | =C++=[fn:139] | OCaml | =ocaml= | -| Clojure | =clojure= | Octave | =octave= | -| CSS | =css= | Org mode | =org= | -| D | =D=[fn:140] | Oz | =oz= | -| ditaa | =ditaa= | Perl | =perl= | -| Emacs Calc | =calc= | Plantuml | =plantuml= | -| Emacs Lisp | =emacs-lisp= | Processing.js | =processing= | -| Fortran | =fortran= | Python | =python= | -| Gnuplot | =gnuplot= | R | =R= | -| GNU Screen | =screen= | Ruby | =ruby= | -| Graphviz | =dot= | Sass | =sass= | -| Haskell | =haskell= | Scheme | =scheme= | -| Java | =java= | Sed | =sed= | -| Javascript | =js= | shell | =sh= | -| LaTeX | =latex= | SQL | =sql= | -| Ledger | =ledger= | SQLite | =sqlite= | -| Lilypond | =lilypond= | Vala | =vala= | -| Lisp | =lisp= | | | +| Language | Identifier | Language | Identifier | +|------------+---------------+----------------+--------------| +| Asymptote | =asymptote= | Lisp | =lisp= | +| Awk | =awk= | Lua | =lua= | +| C | =C= | MATLAB | =matlab= | +| C++ | =C++=[fn:135] | Mscgen | =mscgen= | +| Clojure | =clojure= | Objective Caml | =ocaml= | +| CSS | =css= | Octave | =octave= | +| D | =D=[fn:136] | Org mode | =org= | +| ditaa | =ditaa= | Oz | =oz= | +| Emacs Calc | =calc= | Perl | =perl= | +| Emacs Lisp | =emacs-lisp= | Plantuml | =plantuml= | +| Eshell | =eshell= | Processing.js | =processing= | +| Fortran | =fortran= | Python | =python= | +| Gnuplot | =gnuplot= | R | =R= | +| GNU Screen | =screen= | Ruby | =ruby= | +| Graphviz | =dot= | Sass | =sass= | +| Haskell | =haskell= | Scheme | =scheme= | +| Java | =java= | Sed | =sed= | +| Javascript | =js= | shell | =sh= | +| LaTeX | =latex= | SQL | =sql= | +| Ledger | =ledger= | SQLite | =sqlite= | +| Lilypond | =lilypond= | Vala | =vala= | Additional documentation for some languages is at https://orgmode.org/worg/org-contrib/babel/languages.html. diff --git a/lisp/ob-eshell.el b/lisp/ob-eshell.el new file mode 100644 index 000000000..45eb33855 --- /dev/null +++ b/lisp/ob-eshell.el @@ -0,0 +1,105 @@ +;;; ob-eshell.el --- Babel Functions for Eshell -*- lexical-binding: t; -*- + +;; Copyright (C) 2018 Free Software Foundation, Inc. + +;; Author: stardiviner +;; Keywords: literate programming, reproducible research +;; Homepage: https://orgmode.org + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; Org Babel support for evaluating Eshell source code. + +;;; Code: +(require 'ob) +(require 'eshell) + +(defvar org-babel-default-header-args:eshell '()) + +(defun org-babel-execute:eshell (body params) + "Execute a block of Eshell code BODY with PARAMS. +This function is called by `org-babel-execute-src-block'. + +The BODY can be any code which allowed executed in Eshell. +Eshell allow to execute normal shell command and Elisp code. +More details please reference Eshell Info. + +The PARAMS are variables assignments." + (let* ((session (org-babel-eshell-initiate-session + (cdr (assq :session params)))) + (full-body (org-babel-expand-body:generic + body params (org-babel-variable-assignments:eshell params)))) + (if session + (progn + (with-current-buffer session + (dolist (line (split-string full-body "\n")) + (goto-char eshell-last-output-end) + (insert line) + (eshell-send-input)) + ;; get output of last input + ;; TODO: collect all output instead of last command's output. + (goto-char eshell-last-input-end) + (buffer-substring-no-properties (point) eshell-last-output-start))) + (with-temp-buffer + (eshell-command full-body t) + (buffer-string))))) + +(defun org-babel-prep-session:eshell (session params) + "Prepare SESSION according to the header arguments specified in PARAMS." + (let* ((session (org-babel-eshell-initiate-session session)) + ;; Eshell session buffer is read from variable `eshell-buffer-name'. + (eshell-buffer-name session) + (var-lines (org-babel-variable-assignments:eshell params))) + (call-interactively #'eshell) + (mapc #'eshell-command var-lines) + session)) + +(defun ob-eshell-session-live-p (session) + "Non-nil if Eshell SESSION exists." + (get-buffer session)) + +(defun org-babel-eshell-initiate-session (&optional session params) + "Initiate a session named SESSION according to PARAMS." + (when (and session (not (string= session "none"))) + (save-window-excursion + (or (ob-eshell-session-live-p session) + (progn + (let ((eshell-buffer-name session)) + (eshell)) + (get-buffer (current-buffer))))) + session)) + +(defun org-babel-variable-assignments:eshell (params) + "Convert ob-eshell :var specified variables into Eshell variables assignments." + (mapcar + (lambda (pair) + (format "(setq %s %S)" (car pair) (cdr pair))) + (org-babel--get-vars params))) + +(defun org-babel-load-session:eshell (session body params) + "Load BODY into SESSION with PARAMS." + (save-window-excursion + (let ((buffer (org-babel-prep-session:eshell session params))) + (with-current-buffer buffer + (goto-char (point-max)) + (insert (org-babel-chomp body))) + buffer))) + +(provide 'ob-eshell) + +;;; ob-eshell.el ends here diff --git a/testing/lisp/test-ob-eshell.el b/testing/lisp/test-ob-eshell.el new file mode 100644 index 000000000..5b0eb27c1 --- /dev/null +++ b/testing/lisp/test-ob-eshell.el @@ -0,0 +1,73 @@ +;;; test-ob-eshell.el + +;; Copyright (c) 2018 stardiviner +;; Authors: stardiviner + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Comment: + +;; Template test file for Org tests + +;;; Code: +(unless (featurep 'ob-eshell) + (signal 'missing-test-dependency "Support for Eshell code blocks")) + +(ert-deftest ob-eshell/execute () + "Test ob-eshell execute." + (should + (string= + (org-test-with-temp-text + "#+begin_src eshell +echo 2 +#+end_src" + (org-babel-execute-src-block)) + ": 2"))) + +(ert-deftest ob-eshell/variables-assignment () + "Test ob-eshell variables assignment." + (should + (string= + (org-test-with-temp-text + "#+begin_src eshell :var hi=\"hello, world\" +echo $hi +#+end_src" + (org-babel-execute-src-block)) + ": hello, world"))) + +(ert-deftest ob-eshell/session () + "Test ob-eshell session." + (should + (string= + (org-test-with-temp-text + "#+begin_src eshell :session +(setq hi \"hello, world\") +#+end_src + +#+begin_src eshell :session +echo $hi +#+end_src" + (org-babel-execute-src-block) + (org-babel-next-src-block) + (org-babel-execute-src-block) + (goto-char (org-babel-where-is-src-block-result)) + (forward-line) + (buffer-substring-no-properties (point) (line-end-position))) + ": hello, world"))) + +(provide 'test-ob-eshell) + +;;; test-ob-eshell.el ends here From d956ae04318fdede3e2b7a93dac2a11d13dd0a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= Date: Sat, 2 Jun 2018 10:02:03 +0200 Subject: [PATCH 04/40] Add new :coding parameter to #+include keyword * lisp/ox.el (org-export-expand-include-keyword): Add new parameter `:coding' for specify the file encoding whith the `#+include:' keyword. This allow to use something like: #+include: "./myfile" :coding cp850-dos when your Org file is encoded in utf-8 for example. --- lisp/ox.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/ox.el b/lisp/ox.el index 45c94159a..7b10cdeb2 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3282,6 +3282,11 @@ storing and resolving footnotes. It is created automatically." (let* ((value (org-element-property :value element)) (ind (current-indentation)) location + (coding-system-for-read + (or (and (string-match ":coding +\\(\\S-+\\)>" value) + (prog1 (intern (match-string 1 value)) + (setq value (replace-match "" nil nil value)))) + coding-system-for-read)) (file (and (string-match "^\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)" value) From 74f769f85045bd37bbe4cdd953613cf4a38de673 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 2 Jun 2018 11:55:13 +0200 Subject: [PATCH 05/40] ob-shell: Silence byte-compilation * lisp/ob-eshell.el (org-babel-eshell-initiate-session): Silence byte-compilation. --- lisp/ob-eshell.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob-eshell.el b/lisp/ob-eshell.el index 45eb33855..29aa07c30 100644 --- a/lisp/ob-eshell.el +++ b/lisp/ob-eshell.el @@ -73,8 +73,8 @@ The PARAMS are variables assignments." "Non-nil if Eshell SESSION exists." (get-buffer session)) -(defun org-babel-eshell-initiate-session (&optional session params) - "Initiate a session named SESSION according to PARAMS." +(defun org-babel-eshell-initiate-session (&optional session _params) + "Initiate a session named SESSION." (when (and session (not (string= session "none"))) (save-window-excursion (or (ob-eshell-session-live-p session) From d0a5308435d35c21d24965383970cd70d61f5886 Mon Sep 17 00:00:00 2001 From: Chris Kauffman Date: Sun, 23 Jul 2017 00:13:11 -0400 Subject: [PATCH 06/40] org-table: Adding single cell movement functions * lisp/org-table.el (org-table--swap-cells): (org-table--move-cell): (org-table-move-cell-up): (org-table-move-cell-down): (org-table-move-cell-left): (org-table-move-cell-right): New functions. * testing/lisp/test-org-table.el (test-org-table/move-cell-down): (test-org-table/move-cell-up): (test-org-table/move-cell-right): (test-org-table/move-cell-left): New tests. * doc/org-manual.org (Column and row editing): Document functions and keybindings for single cell movement. --- doc/org-manual.org | 24 ++ lisp/org-table.el | 74 +++++++ testing/lisp/test-org-table.el | 385 +++++++++++++++++++++++++++++++++ 3 files changed, 483 insertions(+) diff --git a/doc/org-manual.org b/doc/org-manual.org index 535aa9d7f..9db00923d 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -1556,6 +1556,30 @@ you, configure the option ~org-table-auto-blank-field~. #+findex: org-table-kill-row Kill the current row or horizontal line. +- {{{kbd(S-UP)}}} (~org-table-move-cell-up~) :: + + #+kindex: S-UP + #+findex: org-table-move-cell-up + Move cell up by swapping with adjacent cell. + +- {{{kbd(S-DOWN)}}} (~org-table-move-cell-down~) :: + + #+kindex: S-DOWN + #+findex: org-table-move-cell-down + Move cell down by swapping with adjacent cell. + +- {{{kbd(S-LEFT)}}} (~org-table-move-cell-left~) :: + + #+kindex: S-LEFT + #+findex: org-table-move-cell-left + Move cell left by swapping with adjacent cell. + +- {{{kbd(S-RIGHT)}}} (~org-table-move-cell-right~) :: + + #+kindex: S-RIGHT + #+findex: org-table-move-cell-right + Move cell right by swapping with adjacent cell. + - {{{kbd(M-S-DOWN)}}} (~org-table-insert-row~) :: #+kindex: M-S-DOWN diff --git a/lisp/org-table.el b/lisp/org-table.el index 8eb38ef68..634dd148d 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -1442,6 +1442,80 @@ non-nil, the one above is used." (above min) (t max))))))) +(defun org-table--swap-cells (row1 col1 row2 col2) + "Swap two cells indicated by the coordinates provided. +ROW1, COL1, ROW2, COL2 are integers indicating the row/column +position of the two cells that will be swapped in the table." + (let ((content1 (org-table-get row1 col1)) + (content2 (org-table-get row2 col2))) + (org-table-put row1 col1 content2) + (org-table-put row2 col2 content1))) + +(defun org-table--move-cell (direction) + "Move the current cell in a cardinal direction. +DIRECTION is a symbol among `up', `down', `left', and `right'. +The contents the current cell are swapped with cell in the +indicated direction. Raise an error if the move cannot be done." + (let ((row-shift (pcase direction (`up -1) (`down 1) (_ 0))) + (column-shift (pcase direction (`left -1) (`right 1) (_ 0)))) + (when (and (= 0 row-shift) (= 0 column-shift)) + (error "Invalid direction: %S" direction)) + ;; Initialize `org-table-current-ncol' and `org-table-dlines'. + (org-table-analyze) + (let* ((row (org-table-current-line)) + (column (org-table-current-column)) + (target-row (+ row row-shift)) + (target-column (+ column column-shift)) + (org-table-current-nrow (1- (length org-table-dlines)))) + (when (or (< target-column 1) + (< target-row 1) + (> target-column org-table-current-ncol) + (> target-row org-table-current-nrow)) + (user-error "Cannot move cell further")) + (org-table--swap-cells row column target-row target-column) + (org-table-goto-line target-row) + (org-table-goto-column target-column)))) + +;;;###autoload +(defun org-table-move-cell-up () + "Move a single cell up in a table. +Swap with anything in target cell." + (interactive) + (unless (org-table-check-inside-data-field) + (error "No table at point")) + (org-table--move-cell 'up) + (org-table-align)) + +;;;###autoload +(defun org-table-move-cell-down () + "Move a single cell down in a table. +Swap with anything in target cell." + (interactive) + (unless (org-table-check-inside-data-field) + (error "No table at point")) + (org-table--move-cell 'down) + (org-table-align)) + +;;;###autoload +(defun org-table-move-cell-left () + "Move a single cell left in a table. +Swap with anything in target cell." + (interactive) + (unless (org-table-check-inside-data-field) + (error "No table at point")) + (org-table--move-cell 'left) + (org-table-align)) + +;;;###autoload +(defun org-table-move-cell-right () + "Move a single cell right in a table. +Swap with anything in target cell." + (interactive) + (unless (org-table-check-inside-data-field) + (error "No table at point")) + (org-table--move-cell 'right) + (org-table-align)) + ;;;###autoload (defun org-table-delete-column () "Delete a column from the table." diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index ecef7ea8e..7af5c9f0b 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -2277,6 +2277,391 @@ See also `test-org-table/copy-field'." (buffer-string))))) + +;;; Moving single cells +(ert-deftest test-org-table/move-cell-down () + "Test `org-table-move-cell-down' specifications." + ;; Error out when cell cannot be moved due to not in table, in the + ;; last row of the table, or is on a hline. + (should-error + (org-test-with-temp-text "not in\na table\n" + (org-table-move-cell-down))) + (should-error + (org-test-with-temp-text "| a |" + (org-table-move-cell-down))) + (should-error + (org-test-with-temp-text "| a |\n" + (org-table-move-cell-down))) + (should-error + (org-test-with-temp-text "| a | b |\n" + (org-table-move-cell-down))) + (should-error + (org-test-with-temp-text "| a | b |\n| c | d |\n" + (org-table-move-cell-down))) + (should-error + (org-test-with-temp-text "| a | b |\n| c | d |\n" + (org-table-move-cell-down))) + (should-error + (org-test-with-temp-text "| a |\n|---|\n" + (org-table-move-cell-down))) + (should-error + (org-test-with-temp-text "|---|\n| a |\n" + (org-table-move-cell-down))) + ;; Check for correct cell movement + (should (equal (concat "| c | b |\n" + "| a | d |\n" + "| e | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-down) + (buffer-string)))) + (should (equal (concat "| a | d |\n" + "| c | b |\n" + "| e | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-down) + (buffer-string)))) + (should (equal (concat "| a | b |\n" + "| e | d |\n" + "| c | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-down) + (buffer-string)))) + (should (equal (concat "| a | d |\n" + "| c | f |\n" + "| e | b |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-down) + (org-table-move-cell-down) + (buffer-string)))) + ;; Check for correct handling of hlines which should not change + ;; position on single cell moves. + (should (equal (concat "| c | b |\n" + "|---+---|\n" + "| a | d |\n" + "| e | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-down) + (buffer-string)))) + (should (equal (concat "| a | d |\n" + "|---+---|\n" + "| c | f |\n" + "| e | b |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-down) + (org-table-move-cell-down) + (buffer-string)))) + (should (equal (concat "| a | b |\n" + "|---+---|\n" + "| c | f |\n" + "| e | d |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-down) + (buffer-string)))) + ;; Move single cell even without a final newline. + (should (equal (concat "| a | d |\n" + "|---+---|\n" + "| c | f |\n" + "| e | b |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |") + (org-table-move-cell-down) + (org-table-move-cell-down) + (buffer-string))))) + +(ert-deftest test-org-table/move-cell-up () + "Test `org-table-move-cell-up' specifications." + ;; Error out when cell cannot be moved due to not in table, in the + ;; last row of the table, or is on a hline. + (should-error + (org-test-with-temp-text "not in\na table\n" + (org-table-move-cell-up))) + (should-error + (org-test-with-temp-text "| a |" + (org-table-move-cell-up))) + (should-error + (org-test-with-temp-text "| a |\n" + (org-table-move-cell-up))) + (should-error + (org-test-with-temp-text "| a | b |\n" + (org-table-move-cell-up))) + (should-error + (org-test-with-temp-text "| a | b |\n| c | d |\n" + (org-table-move-cell-up))) + (should-error + (org-test-with-temp-text "| a |\n|---|\n" + (org-table-move-cell-up))) + (should-error + (org-test-with-temp-text "|---|\n| a |\n" + (org-table-move-cell-up))) + ;; Check for correct cell movement. + (should (equal (concat "| c | b |\n" + "| a | d |\n" + "| e | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-up) + (buffer-string)))) + (should (equal (concat "| a | d |\n" + "| c | b |\n" + "| e | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-up) + (buffer-string)))) + (should (equal (concat "| a | b |\n" + "| e | d |\n" + "| c | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-up) + (buffer-string)))) + (should (equal (concat "| a | f |\n" + "| c | b |\n" + "| e | d |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-up) + (org-table-move-cell-up) + (buffer-string)))) + ;; Check for correct handling of hlines which should not change + ;; position on single cell moves. + (should (equal (concat "| c | b |\n" + "|---+---|\n" + "| a | d |\n" + "| e | f |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-up) + (buffer-string)))) + (should (equal (concat "| a | f |\n" + "|---+---|\n" + "| c | b |\n" + "| e | d |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-up) + (org-table-move-cell-up) + (buffer-string)))) + (should (equal (concat "| a | b |\n" + "|---+---|\n" + "| c | f |\n" + "| e | d |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |\n") + (org-table-move-cell-up) + (buffer-string)))) + ;; Move single cell even without a final newline. + (should (equal (concat "| a | f |\n" + "|---+---|\n" + "| c | b |\n" + "| e | d |\n") + (org-test-with-temp-text + (concat "| a | b |\n" + "|---+---|\n" + "| c | d |\n" + "| e | f |") + (org-table-move-cell-up) + (org-table-move-cell-up) + (buffer-string))))) + +(ert-deftest test-org-table/move-cell-right () + "Test `org-table-move-cell-right' specifications." + ;; Error out when cell cannot be moved due to not in table, in the + ;; last col of the table, or is on a hline. + (should-error + (org-test-with-temp-text "not in\na table\n" + (org-table-move-cell-right))) + (should-error + (org-test-with-temp-text "| a |" + (org-table-move-cell-right))) + (should-error + (org-test-with-temp-text "| a |\n" + (org-table-move-cell-right))) + (should-error + (org-test-with-temp-text "| a |\n| b |\n" + (org-table-move-cell-right))) + (should-error + (org-test-with-temp-text "| a | b |\n| c | d |\n" + (org-table-move-cell-right))) + (should-error + (org-test-with-temp-text "| a |\n|---|\n" + (org-table-move-cell-right))) + (should-error + (org-test-with-temp-text "|---|\n| a |\n" + (org-table-move-cell-right))) + ;; Check for correct cell movement. + (should (equal (concat "| b | a | c |\n" + "| d | e | f |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-right) + (buffer-string)))) + (should (equal (concat "| b | c | a |\n" + "| d | e | f |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-right) + (org-table-move-cell-right) + (buffer-string)))) + (should (equal (concat "| a | b | c |\n" + "| e | f | d |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-right) + (org-table-move-cell-right) + (buffer-string)))) + (should (equal (concat "| a | b | c |\n" + "| d | f | e |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-right) + (buffer-string)))) + (should (equal (concat "| a | b | c |\n" + "|---+---+---|\n" + "| e | f | d |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "|---+---+---|\n" + "| d | e | f |\n") + (org-table-move-cell-right) + (org-table-move-cell-right) + (buffer-string)))) + ;; Move single cell even without a final newline. + (should (equal (concat "| a | b | c |\n" + "|---+---+---|\n" + "| e | d | f |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "|---+---+---|\n" + "| d | e | f |") + (org-table-move-cell-right) + (buffer-string))))) + +(ert-deftest test-org-table/move-cell-left () + "Test `org-table-move-cell-left' specifications." + ;; Error out when cell cannot be moved due to not in table, in the + ;; last col of the table, or is on a hline. + (should-error + (org-test-with-temp-text "not in\na table\n" + (org-table-move-cell-left))) + (should-error + (org-test-with-temp-text "| a |" + (org-table-move-cell-left))) + (should-error + (org-test-with-temp-text "| a |\n" + (org-table-move-cell-left))) + (should-error + (org-test-with-temp-text "| a |\n| b |\n" + (org-table-move-cell-left))) + (should-error + (org-test-with-temp-text "| a | b |\n| c | d |\n" + (org-table-move-cell-left))) + (should-error + (org-test-with-temp-text "| a |\n|---|\n" + (org-table-move-cell-left))) + (should-error + (org-test-with-temp-text "|---|\n| a |\n" + (org-table-move-cell-left))) + ;; Check for correct cell movement. + (should (equal (concat "| b | a | c |\n" + "| d | e | f |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-left) + (buffer-string)))) + (should (equal (concat "| c | a | b |\n" + "| d | e | f |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-left) + (org-table-move-cell-left) + (buffer-string)))) + (should (equal (concat "| a | b | c |\n" + "| f | d | e |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-left) + (org-table-move-cell-left) + (buffer-string)))) + (should (equal (concat "| a | b | c |\n" + "| d | f | e |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "| d | e | f |\n") + (org-table-move-cell-left) + (buffer-string)))) + (should (equal (concat "| a | b | c |\n" + "|---+---+---|\n" + "| f | d | e |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "|---+---+---|\n" + "| d | e | f |\n") + (org-table-move-cell-left) + (org-table-move-cell-left) + (buffer-string)))) + ;; Move single cell even without a final newline. + (should (equal (concat "| a | b | c |\n" + "|---+---+---|\n" + "| e | d | f |\n") + (org-test-with-temp-text + (concat "| a | b | c |\n" + "|---+---+---|\n" + "| d | e | f |") + (org-table-move-cell-left) + (buffer-string))))) + ;;; Moving rows, moving columns From 09f9507238aa015efe819a7f5af091412f6cf486 Mon Sep 17 00:00:00 2001 From: Chris Kauffman Date: Fri, 28 Jul 2017 22:06:05 -0400 Subject: [PATCH 07/40] Added keybindings for `org-table-move-cell-*' functions * lisp/org.el (org-shiftup): (org-shiftdown): (org-shiftright): (org-shiftleft): Dispatch `org-table-move-cell-*' commands. --- lisp/org.el | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a65b07994..68076e919 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19842,9 +19842,10 @@ commands for more information." (t (org-drag-element-forward)))) (defun org-shiftup (&optional arg) - "Increase item in timestamp or increase priority of current headline. -Calls `org-timestamp-up' or `org-priority-up', or `org-previous-item', -depending on context. See the individual commands for more information." + "Act on current element according to context. +Call `org-timestamp-up' or `org-priority-up', or +`org-previous-item', or `org-table-move-cell-up'. See the +individual commands for more information." (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftup-hook)) @@ -19860,15 +19861,17 @@ depending on context. See the individual commands for more information." ((and (not org-support-shift-select) (org-at-item-p)) (call-interactively 'org-previous-item)) ((org-clocktable-try-shift 'up arg)) + ((org-at-table-p) (org-table-move-cell-up)) ((run-hook-with-args-until-success 'org-shiftup-final-hook)) (org-support-shift-select (org-call-for-shift-select 'previous-line)) (t (org-shiftselect-error)))) (defun org-shiftdown (&optional arg) - "Decrease item in timestamp or decrease priority of current headline. -Calls `org-timestamp-down' or `org-priority-down', or `org-next-item' -depending on context. See the individual commands for more information." + "Act on current element according to context. +Call `org-timestamp-down' or `org-priority-down', or +`org-next-item', or `org-table-move-cell-down'. See the +individual commands for more information." (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftdown-hook)) @@ -19884,20 +19887,22 @@ depending on context. See the individual commands for more information." ((and (not org-support-shift-select) (org-at-item-p)) (call-interactively 'org-next-item)) ((org-clocktable-try-shift 'down arg)) + ((org-at-table-p) (org-table-move-cell-down)) ((run-hook-with-args-until-success 'org-shiftdown-final-hook)) (org-support-shift-select (org-call-for-shift-select 'next-line)) (t (org-shiftselect-error)))) (defun org-shiftright (&optional arg) - "Cycle the thing at point or in the current line, depending on context. -Depending on context, this does one of the following: + "Act on the current element according to context. +This does one of the following: - switch a timestamp at point one day into the future - on a headline, switch to the next TODO keyword. - on an item, switch entire list to the next bullet type - on a property line, switch to the next allowed value -- on a clocktable definition line, move time block into the future" +- on a clocktable definition line, move time block into the future +- in a table, move a single cell right" (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftright-hook)) @@ -19920,20 +19925,22 @@ Depending on context, this does one of the following: (org-at-property-p)) (call-interactively 'org-property-next-allowed-value)) ((org-clocktable-try-shift 'right arg)) + ((org-at-table-p) (org-table-move-cell-right)) ((run-hook-with-args-until-success 'org-shiftright-final-hook)) (org-support-shift-select (org-call-for-shift-select 'forward-char)) (t (org-shiftselect-error)))) (defun org-shiftleft (&optional arg) - "Cycle the thing at point or in the current line, depending on context. -Depending on context, this does one of the following: + "Act on current element according to context. +This does one of the following: - switch a timestamp at point one day into the past - on a headline, switch to the previous TODO keyword. - on an item, switch entire list to the previous bullet type - on a property line, switch to the previous allowed value -- on a clocktable definition line, move time block into the past" +- on a clocktable definition line, move time block into the past +- in a table, move a single cell left" (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftleft-hook)) @@ -19956,6 +19963,7 @@ Depending on context, this does one of the following: (org-at-property-p)) (call-interactively 'org-property-previous-allowed-value)) ((org-clocktable-try-shift 'left arg)) + ((org-at-table-p) (org-table-move-cell-left)) ((run-hook-with-args-until-success 'org-shiftleft-final-hook)) (org-support-shift-select (org-call-for-shift-select 'backward-char)) From 3109e2e02eb8a2fab0a9deb6ef80952933d8f026 Mon Sep 17 00:00:00 2001 From: Chris Kauffman Date: Fri, 28 Jul 2017 22:46:12 -0400 Subject: [PATCH 08/40] orgguide.texi: Document single cell movement functions * doc/orgguide.texi (Tables): Add keybindings for since cell movement. --- doc/orgguide.texi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/orgguide.texi b/doc/orgguide.texi index 297856c44..d9f755c30 100644 --- a/doc/orgguide.texi +++ b/doc/orgguide.texi @@ -646,6 +646,12 @@ Re-align, move to previous field. @item @key{RET} Re-align the table and move down to next row. Creates a new row if necessary. +@c +@item S-@key{up} +@itemx S-@key{down} +@itemx S-@key{left} +@itemx S-@key{right} +Move a cell up, down, left, and right by swapping with adjacent cell. @tsubheading{Column and row editing} @item M-@key{left} From 37f3fbf3c6a1b7d4b22f231dc0a818ecddb907d2 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 13 Jun 2018 15:32:11 +0200 Subject: [PATCH 09/40] ORG-NEWS: Document cell movement in tables --- etc/ORG-NEWS | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 5ba98ca97..2f8372e85 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -12,10 +12,18 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.3 -** Babel - -*** Add LaTeX output support in PlantUML +** New features +*** Babel +**** Add LaTeX output support in PlantUML +*** New cell movement functions in tables +~S-~, ~S-~, ~S-~, and ~S-~ now move cells in +the corresponding direction by swapping with the adjacent cell. +** New functions +*** ~org-table-cell-up~ +*** ~org-table-cell-down~ +*** ~org-table-cell-left~ +*** ~org-table-cell-right~ * Version 9.2 ** Incompatible changes *** Removal of OrgStruct mode mode and radio lists From db56e096e8b8fc9d3d163ea14c158c51c364cc69 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 13 Jun 2018 15:37:56 +0200 Subject: [PATCH 10/40] ORG-NEWS: Document :coding parameter for INCLUDE keywords --- etc/ORG-NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 2f8372e85..7312a338e 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -15,6 +15,14 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. ** New features *** Babel **** Add LaTeX output support in PlantUML +*** New parameter for =INCLUDE= keyword +Add =:coding CODING-SYSTEM= to include files using a different coding +system than the main Org document. For example: + +#+begin_example +,#+INCLUDE: "myfile.cmd" src cmd :coding cp850-dos +#+end_example + *** New cell movement functions in tables ~S-~, ~S-~, ~S-~, and ~S-~ now move cells in the corresponding direction by swapping with the adjacent cell. From 0ff4076cb4b0f9b7e911afb8780cdc158826133c Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 14 Jun 2018 21:11:22 +0200 Subject: [PATCH 11/40] ob-eshell: Silence byte-compiler * lisp/ob-eshell.el (org-babel-eshell-initiate-session): Remove unnecessary code. --- lisp/ob-eshell.el | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lisp/ob-eshell.el b/lisp/ob-eshell.el index 29aa07c30..800abce2f 100644 --- a/lisp/ob-eshell.el +++ b/lisp/ob-eshell.el @@ -77,11 +77,8 @@ The PARAMS are variables assignments." "Initiate a session named SESSION." (when (and session (not (string= session "none"))) (save-window-excursion - (or (ob-eshell-session-live-p session) - (progn - (let ((eshell-buffer-name session)) - (eshell)) - (get-buffer (current-buffer))))) + (unless (ob-eshell-session-live-p session) + (let ((eshell-buffer-name session)) (eshell)))) session)) (defun org-babel-variable-assignments:eshell (params) From 0dd29855090ae54946ff4cabb23dfc83d002fc23 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 14 Jun 2018 21:47:00 +0200 Subject: [PATCH 12/40] `org-fill-paragraph' leaves buffer unmodified when doing nothing * lisp/org.el (org-fill-paragraph): Leave buffer unmodified when nothing was filled. * lisp/org-compat.el: Add forward compatibility with `buffer-hash' function. --- lisp/org-compat.el | 4 ++++ lisp/org.el | 35 +++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 714ad7848..a72627a61 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -81,6 +81,10 @@ (defalias 'org-line-number-display-width 'line-number-display-width) (defun org-line-number-display-width (&rest _) 0)) +(if (fboundp 'buffer-hash) + (defalias 'org-buffer-hash 'buffer-hash) + (defun org-buffer-hash () (md5 (current-buffer)))) + ;;; Emacs < 25.1 compatibility diff --git a/lisp/org.el b/lisp/org.el index 68076e919..0bda8dfe6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -22154,20 +22154,27 @@ filling the current element." (interactive (progn (barf-if-buffer-read-only) (list (when current-prefix-arg 'full) t))) - (cond - ((and region transient-mark-mode mark-active - (not (eq (region-beginning) (region-end)))) - (let ((origin (point-marker)) - (start (region-beginning))) - (unwind-protect - (progn - (goto-char (region-end)) - (while (> (point) start) - (org-backward-paragraph) - (org-fill-element justify))) - (goto-char origin) - (set-marker origin nil)))) - (t (org-fill-element justify)))) + (let ((hash (and (not (buffer-modified-p)) + (org-buffer-hash)))) + (cond + ((and region transient-mark-mode mark-active + (not (eq (region-beginning) (region-end)))) + (let ((origin (point-marker)) + (start (region-beginning))) + (unwind-protect + (progn + (goto-char (region-end)) + (while (> (point) start) + (org-backward-paragraph) + (org-fill-element justify))) + (goto-char origin) + (set-marker origin nil)))) + (t (org-fill-element justify))) + ;; If we didn't change anything in the buffer (and the buffer was + ;; previously unmodified), then flip the modification status back + ;; to "unchanged". + (when (and hash (equal hash (org-buffer-hash))) + (set-buffer-modified-p nil)))) (defun org-auto-fill-function () "Auto-fill function." From fc5ee0f87bd940d0b7cdaa123f71d7ab0d9db350 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 19 Jun 2018 16:29:30 +0200 Subject: [PATCH 13/40] org-colview: Plain numbers are minutes instead of hours * lisp/org-colview.el (org-columns--summary-apply-times): Use the same rule as everywhere else in Org. * doc/org-manual.org (Column attributes): Document change. Reported-by: Bernt Hansen --- doc/org-manual.org | 2 +- lisp/org-colview.el | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 9db00923d..917c05a24 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -5404,7 +5404,7 @@ optional. The individual parts have the following meaning: | =X= | Checkbox status, =[X]= if all children are =[X]=. | | =X/= | Checkbox status, =[n/m]=. | | =X%= | Checkbox status, =[n%]=. | - | =:= | Sum times, HH:MM, plain numbers are hours. | + | =:= | Sum times, HH:MM, plain numbers are minutes. | | =:min= | Smallest time value in column. | | =:max= | Largest time value. | | =:mean= | Arithmetic mean of time values. | diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 932275836..61a360ec0 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1110,16 +1110,7 @@ as a canonical duration, i.e., using units defined in "Apply FUN to time values TIMES. Return the result as a duration." (org-duration-from-minutes - (apply fun - (mapcar (lambda (time) - ;; Unlike to `org-duration-to-minutes' standard - ;; behavior, we want to consider plain numbers as - ;; hours. As a consequence, we treat them - ;; differently. - (if (string-match-p "\\`[0-9]+\\(?:\\.[0-9]*\\)?\\'" time) - (* 60 (string-to-number time)) - (org-duration-to-minutes time))) - times)) + (apply fun (mapcar #'org-duration-to-minutes times)) (org-duration-h:mm-only-p times))) (defun org-columns--compute-spec (spec &optional update) From 19d545a0a8304558abb24b83d4226f57f70ffc5d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 19 Jun 2018 16:34:07 +0200 Subject: [PATCH 14/40] ORG-NEWS: Document last change * etc/ORG-NEWS (Plain numbers are hours in Column View mode): New section. --- etc/ORG-NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 7312a338e..fbbeee7f6 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -12,6 +12,12 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.3 +** Incompatible change + +*** Plain numbers are hours in Column View mode + +See [[git:3367ac9457]] for details. + ** New features *** Babel **** Add LaTeX output support in PlantUML From 6995f206adc8264f56181172dced4adc3239631d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 21 Jun 2018 22:05:17 +0200 Subject: [PATCH 15/40] org-colview: Fix failing test * testing/lisp/test-org-colview.el (test-org-colview/columns-summary): Fix failing test. Since 3367ac945796d7b65feb3c2d0ceb9734a6bbd19c, plain numbers in properties are minutes instead of hours. --- testing/lisp/test-org-colview.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el index fd00a2dde..6315d86c4 100644 --- a/testing/lisp/test-org-colview.el +++ b/testing/lisp/test-org-colview.el @@ -224,7 +224,7 @@ :END:" (let ((org-columns-default-format "%A{+;%.1f}")) (org-columns)) (get-char-property (point) 'org-columns-value-modified)))) - ;; {:} sums times. Plain numbers are hours. + ;; {:} sums times. Plain numbers are minutes. (should (equal "4:10" @@ -242,7 +242,7 @@ (get-char-property (point) 'org-columns-value-modified)))) (should (equal - "3:30" + "1:32" (org-test-with-temp-text "* H ** S1 From 0266c36645e2c3ee56be3318466e78b8c43649a8 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 25 Jun 2018 17:50:44 +0200 Subject: [PATCH 16/40] Do not use `org-refresh-effort-properties' when initializing Org * lisp/org.el (org-mode): Do not call `org-refresh-effort-properties'. (org-set-effort): Avoid using `effort' text property. * lisp/org-timer.el (org-timer-set-timer): Avoid using `effort-minutes' text property. Limit use of `effort' and `effort-minutes' properties to "org-agenda". --- lisp/org-timer.el | 4 +++- lisp/org.el | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/org-timer.el b/lisp/org-timer.el index 55f8ae4d0..21e2e373e 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -438,7 +438,9 @@ using three `C-u' prefix arguments." (if (numberp org-timer-default-timer) (number-to-string org-timer-default-timer) org-timer-default-timer)) - (effort-minutes (ignore-errors (floor (org-get-at-eol 'effort-minutes 1)))) + (effort-minutes (let ((effort (org-entry-get nil org-effort-property))) + (when (org-string-nw-p effort) + (floor (org-duration-to-minutes effort))))) (minutes (or (and (numberp opt) (number-to-string opt)) (and (not (equal opt '(64))) effort-minutes diff --git a/lisp/org.el b/lisp/org.el index 0bda8dfe6..6852deeb9 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5573,8 +5573,7 @@ The following commands are available: (when org-startup-with-latex-preview (org-toggle-latex-fragment '(16))) (unless org-inhibit-startup-visibility-stuff (org-set-startup-visibility)) (when org-startup-truncated (setq truncate-lines t)) - (when org-startup-indented (require 'org-indent) (org-indent-mode 1)) - (org-refresh-effort-properties))) + (when org-startup-indented (require 'org-indent) (org-indent-mode 1)))) ;; Try to set `org-hide' face correctly. (let ((foreground (org-find-invisible-foreground))) (when foreground @@ -15007,7 +15006,7 @@ variables is set." value) (when (equal (org-get-heading t t t t) (bound-and-true-p org-clock-current-task)) - (setq org-clock-effort (org-get-at-bol 'effort)) + (setq org-clock-effort value) (org-clock-update-mode-line)) (message "%s is now %s" org-effort-property value))) From 3fddb59ddc2a97fafd68ac48ea27dd230e990e18 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Fri, 11 Aug 2017 22:18:06 +0200 Subject: [PATCH 17/40] ox-icalendar: Add support for the iCalendar CLASS property * ox-icalendar.el (org-icalendar-entry): Pick the CLASS property and pass it to `org-icalendar--vevent' and `org-icalendar--vtodo'. (org-icalendar--vevent,org-icalendar--vtodo): Add a new parameter `class' and use it to generate a `CLASS' field in the `VEVENT' entry. TINYCHANGE --- lisp/ox-icalendar.el | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index 7d7c85004..426dd6920 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -540,6 +540,10 @@ inlinetask within the section." (org-export-get-node-property :LOCATION entry (org-property-inherit-p "LOCATION")))) + (class (org-icalendar-cleanup-string + (org-export-get-node-property + :CLASS entry + (org-property-inherit-p "CLASS")))) ;; Build description of the entry from associated section ;; (headline) or contents (inlinetask). (desc @@ -568,14 +572,14 @@ inlinetask within the section." org-icalendar-use-deadline) (org-icalendar--vevent entry deadline (concat "DL-" uid) - (concat "DL: " summary) loc desc cat tz))) + (concat "DL: " summary) loc desc cat tz class))) (let ((scheduled (org-element-property :scheduled entry))) (and scheduled (memq (if todo-type 'event-if-todo 'event-if-not-todo) org-icalendar-use-scheduled) (org-icalendar--vevent entry scheduled (concat "SC-" uid) - (concat "S: " summary) loc desc cat tz))) + (concat "S: " summary) loc desc cat tz class))) ;; When collecting plain timestamps from a headline and its ;; title, skip inlinetasks since collection will happen once ;; ENTRY is one of them. @@ -593,7 +597,7 @@ inlinetask within the section." ((t) t))) (let ((uid (format "TS%d-%s" (cl-incf counter) uid))) (org-icalendar--vevent - entry ts uid summary loc desc cat tz)))) + entry ts uid summary loc desc cat tz class)))) info nil (and (eq type 'headline) 'inlinetask)) "")) ;; Task: First check if it is appropriate to export it. If @@ -607,7 +611,7 @@ inlinetask within the section." (not (org-icalendar-blocked-headline-p entry info)))) ((t) (eq todo-type 'todo)))) - (org-icalendar--vtodo entry uid summary loc desc cat tz)) + (org-icalendar--vtodo entry uid summary loc desc cat tz class)) ;; Diary-sexp: Collect every diary-sexp element within ENTRY ;; and its title, and transcode them. If ENTRY is ;; a headline, skip inlinetasks: they will be handled @@ -638,7 +642,7 @@ inlinetask within the section." contents)))) (defun org-icalendar--vevent - (entry timestamp uid summary location description categories timezone) + (entry timestamp uid summary location description categories timezone class) "Create a VEVENT component. ENTRY is either a headline or an inlinetask element. TIMESTAMP @@ -648,7 +652,9 @@ summary or subject for the event. LOCATION defines the intended venue for the event. DESCRIPTION provides the complete description of the event. CATEGORIES defines the categories the event belongs to. TIMEZONE specifies a time zone for this event -only. +only. CLASS contains the visibility attribute. Three of them +(\"PUBLIC\", \"CONFIDENTIAL\", and \"PRIVATE\") are predefined, others +should be treated as \"PRIVATE\" if they are unknown to the iCalendar server. Return VEVENT component as a string." (org-icalendar-fold-string @@ -669,6 +675,7 @@ Return VEVENT component as a string." (org-element-property :repeater-value timestamp))) "SUMMARY:" summary "\n" (and (org-string-nw-p location) (format "LOCATION:%s\n" location)) + (and (org-string-nw-p class) (format "CLASS:%s\n" class)) (and (org-string-nw-p description) (format "DESCRIPTION:%s\n" description)) "CATEGORIES:" categories "\n" @@ -677,7 +684,7 @@ Return VEVENT component as a string." "END:VEVENT")))) (defun org-icalendar--vtodo - (entry uid summary location description categories timezone) + (entry uid summary location description categories timezone class) "Create a VTODO component. ENTRY is either a headline or an inlinetask element. UID is the @@ -712,6 +719,7 @@ Return VTODO component as a string." "\n")) "SUMMARY:" summary "\n" (and (org-string-nw-p location) (format "LOCATION:%s\n" location)) + (and (org-string-nw-p class) (format "CLASS:%s\n" class)) (and (org-string-nw-p description) (format "DESCRIPTION:%s\n" description)) "CATEGORIES:" categories "\n" From 3b0c5f911a771f53b3d5c4284ab8d70fc0dbd2b9 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Tue, 26 Jun 2018 10:05:41 +0200 Subject: [PATCH 18/40] org-manual: Add support for the iCalendar CLASS property * doc/org-manual.org (iCalendar export): Document the CLASS tag TINYCHANGE --- doc/org-manual.org | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 917c05a24..85e54b31e 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -15048,18 +15048,20 @@ connections. #+cindex: @samp{DESCRIPTION}, property #+cindex: @samp{LOCATION}, property #+cindex: @samp{TIMEZONE}, property +#+cindex: @samp{CLASS}, property The iCalendar export back-end includes =SUMMARY=, =DESCRIPTION=, -=LOCATION= and =TIMEZONE= properties from the Org entries when -exporting. To force the back-end to inherit the =LOCATION= and -=TIMEZONE= properties, configure the ~org-use-property-inheritance~ -variable. +=LOCATION=, =TIMEZONE= and =CLASS= properties from the Org entries +when exporting. To force the back-end to inherit the =LOCATION=, +=TIMEZONE= and =CLASS= properties, configure the +~org-use-property-inheritance~ variable. #+vindex: org-icalendar-include-body -When Org entries do not have =SUMMARY=, =DESCRIPTION= and =LOCATION= -properties, the iCalendar export back-end derives the summary from the -headline, and derives the description from the body of the Org item. -The ~org-icalendar-include-body~ variable limits the maximum number of -characters of the content are turned into its description. +When Org entries do not have =SUMMARY=, =DESCRIPTION=, =LOCATION= and +=CLASS= properties, the iCalendar export back-end derives the summary +from the headline, and derives the description from the body of the +Org item. The ~org-icalendar-include-body~ variable limits the +maximum number of characters of the content are turned into its +description. The =TIMEZONE= property can be used to specify a per-entry time zone, and is applied to any entry with timestamp information. Time zones @@ -15067,6 +15069,16 @@ should be specified as per the IANA time zone database format, e.g., =Asia/Almaty=. Alternately, the property value can be =UTC=, to force UTC time for this entry only. +The =CLASS= property can be used to specify a per-entry visibility +class or access restrictions, and is applied to any entry with class +information. The iCalendar standard defines three visibility classes: +- =PUBLIC= :: The entry is publicly visible (this is the default). +- =CONFIDENTIAL= :: Only a limited group of clients get access to the + event. +- =PRIVATE= :: The entry can be retrieved only by its owner. +The server should treat unknown class properties the same as +=PRIVATE=. + Exporting to iCalendar format depends in large part on the capabilities of the destination application. Some are more lenient than others. Consult the Org mode FAQ for advice on specific From 72cadea3c09dd6a1164d010e1f1d66ccb5417cfc Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 27 Jun 2018 08:22:16 +0200 Subject: [PATCH 19/40] ORG-NEWS: Document "CLASS" property * etc/ORG-NEWS (iCalendar export respects a =CLASS= property): New section. --- etc/ORG-NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index fbbeee7f6..fee8dafca 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -21,6 +21,18 @@ See [[git:3367ac9457]] for details. ** New features *** Babel **** Add LaTeX output support in PlantUML +*** iCalendar export respects a =CLASS= property + +Set the =CLASS= property on an entry to specify a visibility class for +that entry only during iCalendar export. The property can be set to +anything the calendar server supports. The iCalendar standard defines +the values =PUBLIC=, =CONFIDENTIAL=, =PRIVATE=, which can be +interpreted as publicly visable, accessible to a specific group, and +private respectively. + +This property can be inherited during iCalendar export, depending on +the value of ~org-use-property-inheritance~. + *** New parameter for =INCLUDE= keyword Add =:coding CODING-SYSTEM= to include files using a different coding system than the main Org document. For example: From 144c27e39d61eb11058c556781e6be3fd31ff199 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 2 Jul 2018 16:06:38 +0200 Subject: [PATCH 20/40] org-keys: Extract key bindings into their own library * lisp/org.el (org-replace-disputed): (org-use-extra-keys): (org-disputed-keys): (org-key): (org-defkey): (org-use-speed-commands): (org-speed-commands-user): (org-follow-link-hook): (org-tab-follows-link): (org-return-follows-link): (org-return-follows-link): (org-mouse-1-follows-link): (org-mouse-map): (org-read-date-minibuffer-local-map): (org-remap): (org-speed-commands-default): (org-print-speed-command): (org-speed-command-help): (org-speed-move-safe): (org-speed-command-activate): (org-babel-speed-command-activate): (org-speed-command-hook): Move to "org-keys.el". * lisp/org-keys.el: New file. * lisp/ob-keys.el: Remove file. --- lisp/ob-keys.el | 106 ------ lisp/ob.el | 2 +- lisp/org-keys.el | 915 +++++++++++++++++++++++++++++++++++++++++++++++ lisp/org-src.el | 4 +- lisp/org.el | 620 +------------------------------- 5 files changed, 920 insertions(+), 727 deletions(-) delete mode 100644 lisp/ob-keys.el create mode 100644 lisp/org-keys.el diff --git a/lisp/ob-keys.el b/lisp/ob-keys.el deleted file mode 100644 index fc96df475..000000000 --- a/lisp/ob-keys.el +++ /dev/null @@ -1,106 +0,0 @@ -;;; ob-keys.el --- Key Bindings for Babel -*- lexical-binding: t; -*- - -;; Copyright (C) 2009-2018 Free Software Foundation, Inc. - -;; Author: Eric Schulte -;; Keywords: literate programming, reproducible research -;; Homepage: https://orgmode.org - -;; This file is part of GNU Emacs. - -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - -;;; Commentary: - -;; Add Org Babel keybindings to the Org mode keymap for exposing -;; Org Babel functions. These will all share a common prefix. See -;; the value of `org-babel-key-bindings' for a list of interactive -;; functions and their associated keys. - -;;; Code: -(require 'ob-core) - -(defvar org-babel-key-prefix "\C-c\C-v" - "The key prefix for Babel interactive key-bindings. -See `org-babel-key-bindings' for the list of interactive babel -functions which are assigned key bindings, and see -`org-babel-map' for the actual babel keymap.") - -(defvar org-babel-map (make-sparse-keymap) - "The keymap for interactive Babel functions.") - -;;;###autoload -(defun org-babel-describe-bindings () - "Describe all keybindings behind `org-babel-key-prefix'." - (interactive) - (describe-bindings org-babel-key-prefix)) - -(defvar org-babel-key-bindings - '(("p" . org-babel-previous-src-block) - ("\C-p" . org-babel-previous-src-block) - ("n" . org-babel-next-src-block) - ("\C-n" . org-babel-next-src-block) - ("e" . org-babel-execute-maybe) - ("\C-e" . org-babel-execute-maybe) - ("o" . org-babel-open-src-block-result) - ("\C-o" . org-babel-open-src-block-result) - ("\C-v" . org-babel-expand-src-block) - ("v" . org-babel-expand-src-block) - ("u" . org-babel-goto-src-block-head) - ("\C-u" . org-babel-goto-src-block-head) - ("g" . org-babel-goto-named-src-block) - ("r" . org-babel-goto-named-result) - ("\C-r" . org-babel-goto-named-result) - ("\C-b" . org-babel-execute-buffer) - ("b" . org-babel-execute-buffer) - ("\C-s" . org-babel-execute-subtree) - ("s" . org-babel-execute-subtree) - ("\C-d" . org-babel-demarcate-block) - ("d" . org-babel-demarcate-block) - ("\C-t" . org-babel-tangle) - ("t" . org-babel-tangle) - ("\C-f" . org-babel-tangle-file) - ("f" . org-babel-tangle-file) - ("\C-c" . org-babel-check-src-block) - ("c" . org-babel-check-src-block) - ("\C-j" . org-babel-insert-header-arg) - ("j" . org-babel-insert-header-arg) - ("\C-l" . org-babel-load-in-session) - ("l" . org-babel-load-in-session) - ("\C-i" . org-babel-lob-ingest) - ("i" . org-babel-lob-ingest) - ("\C-I" . org-babel-view-src-block-info) - ("I" . org-babel-view-src-block-info) - ("\C-z" . org-babel-switch-to-session) - ("z" . org-babel-switch-to-session-with-code) - ("\C-a" . org-babel-sha1-hash) - ("a" . org-babel-sha1-hash) - ("h" . org-babel-describe-bindings) - ("\C-x" . org-babel-do-key-sequence-in-edit-buffer) - ("x" . org-babel-do-key-sequence-in-edit-buffer) - ("k" . org-babel-remove-result-one-or-many) - ("\C-\M-h" . org-babel-mark-block)) - "Alist of key bindings and interactive Babel functions. -This list associates interactive Babel functions -with keys. Each element of this list will add an entry to the -`org-babel-map' using the letter key which is the `car' of the -a-list placed behind the generic `org-babel-key-prefix'.") - -(provide 'ob-keys) - -;; Local variables: -;; generated-autoload-file: "org-loaddefs.el" -;; End: - -;;; ob-keys.el ends here diff --git a/lisp/ob.el b/lisp/ob.el index 35f65ffa8..21ee774ac 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -24,11 +24,11 @@ ;;; Code: (require 'org-macs) (require 'org-compat) +(require 'org-keys) (require 'ob-eval) (require 'ob-core) (require 'ob-comint) (require 'ob-exp) -(require 'ob-keys) (require 'ob-table) (require 'ob-lob) (require 'ob-ref) diff --git a/lisp/org-keys.el b/lisp/org-keys.el new file mode 100644 index 000000000..eeb3ff393 --- /dev/null +++ b/lisp/org-keys.el @@ -0,0 +1,915 @@ +;;; org-keys.el --- Key bindings for Org mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2018 Free Software Foundation, Inc. + +;; Author: Nicolas Goaziou + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; This library adds bindings for Org mode buffers. It also +;; implements both Speed keys and Babel speed keys. See manual for +;; details. + +;;; Code: + +(defvar org-outline-regexp) + +(declare-function org-add-note "org" ()) +(declare-function org-agenda "org" (&optional arg org-keys restriction)) +(declare-function org-agenda-file-to-front "org" (&optional to-end)) +(declare-function org-agenda-remove-restriction-lock "org" (&optional noupdate)) +(declare-function org-agenda-set-restriction-lock "org" (&optional type)) +(declare-function org-archive-subtree "org" (&optional find-done)) +(declare-function org-archive-subtree-default "org" ()) +(declare-function org-archive-subtree-default-with-confirmation "org" ()) +(declare-function org-archive-to-archive-sibling "org" ()) +(declare-function org-at-heading-p "org" (&optional ignored)) +(declare-function org-attach "org" ()) +(declare-function org-backward-element "org" ()) +(declare-function org-backward-heading-same-level "org" (arg &optional invisible-ok)) +(declare-function org-backward-paragraph "org" ()) +(declare-function org-backward-sentence "org" (&optional arg)) +(declare-function org-beginning-of-line "org" (&optional n)) +(declare-function org-clock-cancel "org" ()) +(declare-function org-clock-display "org" (&optional arg)) +(declare-function org-clock-goto "org" (&optional select)) +(declare-function org-clock-in "org" (&optional select start-time)) +(declare-function org-clock-in-last "org" (&optional arg)) +(declare-function org-clock-out "org" (&optional switch-to-state fail-quietly at-time)) +(declare-function org-clock-report "org" (&optional arg)) +(declare-function org-clone-subtree-with-time-shift "org" (n &optional shift)) +(declare-function org-columns "org" (&optional global columns-fmt-string)) +(declare-function org-columns-insert-dblock "org" ()) +(declare-function org-comment-dwim "org" (arg)) +(declare-function org-copy "org" ()) +(declare-function org-copy-special "org" ()) +(declare-function org-copy-visible "org" (beg end)) +(declare-function org-ctrl-c-ctrl-c "org" (&optional arg)) +(declare-function org-ctrl-c-minus "org" ()) +(declare-function org-ctrl-c-ret "org" ()) +(declare-function org-ctrl-c-star "org" ()) +(declare-function org-ctrl-c-tab "org" (&optional arg)) +(declare-function org-cut-special "org" ()) +(declare-function org-cut-subtree "org" (&optional n)) +(declare-function org-cycle "org" (&optional arg)) +(declare-function org-cycle-agenda-files "org" ()) +(declare-function org-date-from-calendar "org" ()) +(declare-function org-dblock-update "org" (&optional arg)) +(declare-function org-deadline "org" (arg1 &optional time)) +(declare-function org-decrease-number-at-point "org" (&optional inc)) +(declare-function org-delete-backward-char "org" (n)) +(declare-function org-delete-char "org" (n)) +(declare-function org-delete-indentation "org" (&optional arg)) +(declare-function org-demote-subtree "org" ()) +(declare-function org-display-outline-path "org" (&optional file current separator just-return-string)) +(declare-function org-down-element "org" ()) +(declare-function org-edit-special "org" (&optional arg)) +(declare-function org-element-at-point "org-element" ()) +(declare-function org-element-type "org-element" (element)) +(declare-function org-emphasize "org" (&optional char)) +(declare-function org-end-of-line "org" (&optional n)) +(declare-function org-entry-put "org" (pom property value)) +(declare-function org-eval-in-calendar "org" (form &optional keepdate)) +(declare-function org-evaluate-time-range "org" (&optional to-buffer)) +(declare-function org-export-dispatch "org" (&optional arg)) +(declare-function org-feed-goto-inbox "org" (feed)) +(declare-function org-feed-update-all "org" ()) +(declare-function org-fill-paragraph "org" (&optional justify region)) +(declare-function org-find-file-at-mouse "org" (ev)) +(declare-function org-footnote-action "org" (&optional special)) +(declare-function org-force-cycle-archived "org" ()) +(declare-function org-force-self-insert "org" (n)) +(declare-function org-forward-element "org" ()) +(declare-function org-forward-heading-same-level "org" (arg &optional invisible-ok)) +(declare-function org-forward-paragraph "org" ()) +(declare-function org-forward-sentence "org" (&optional arg)) +(declare-function org-goto "org" (&optional alternative-interface)) +(declare-function org-goto-calendar "org" (&optional arg)) +(declare-function org-inc-effort "org" ()) +(declare-function org-increase-number-at-point "org" (&optional inc)) +(declare-function org-insert-all-links "org" (arg &optional pre post)) +(declare-function org-insert-drawer "org" (&optional arg drawer)) +(declare-function org-insert-heading-respect-content "org" (&optional invisible-ok)) +(declare-function org-insert-last-stored-link "org" (arg)) +(declare-function org-insert-link "org" (&optional complete-file link-location default-description)) +(declare-function org-insert-structure-template "org" (type)) +(declare-function org-insert-todo-heading "org" (arg &optional force-heading)) +(declare-function org-insert-todo-heading-respect-content "org" (&optional force-state)) +(declare-function org-kill-line "org" (&optional arg)) +(declare-function org-kill-note-or-show-branches "org" ()) +(declare-function org-list-make-subtree "org" ()) +(declare-function org-mark-element "org" ()) +(declare-function org-mark-ring-goto "org" (&optional n)) +(declare-function org-mark-ring-push "org" (&optional pos buffer)) +(declare-function org-mark-subtree "org" (&optional up)) +(declare-function org-match-sparse-tree "org" (&optional todo-only match)) +(declare-function org-meta-return "org" (&optional arg)) +(declare-function org-metadown "org" (&optional _arg)) +(declare-function org-metaleft "org" (&optional _)) +(declare-function org-metaright "org" (&optional _arg)) +(declare-function org-metaup "org" (&optional _arg)) +(declare-function org-narrow-to-block "org" ()) +(declare-function org-narrow-to-element "org" ()) +(declare-function org-narrow-to-subtree "org" ()) +(declare-function org-next-block "org" (arg &optional backward block-regexp)) +(declare-function org-next-link "org" (&optional search-backward)) +(declare-function org-next-visible-heading "org" (arg)) +(declare-function org-open-at-mouse "org" (ev)) +(declare-function org-open-at-point "org" (&optional arg reference-buffer)) +(declare-function org-open-line "org" (n)) +(declare-function org-paste-special "org" (arg)) +(declare-function org-plot/gnuplot "org-plot" (&optional params)) +(declare-function org-previous-block "org" (arg &optional block-regexp)) +(declare-function org-previous-link "org" ()) +(declare-function org-previous-visible-heading "org" (arg)) +(declare-function org-priority "org" (&optional action show)) +(declare-function org-promote-subtree "org" ()) +(declare-function org-redisplay-inline-images "org" ()) +(declare-function org-refile "org" (&optional arg1 default-buffer rfloc msg)) +(declare-function org-reftex-citation "org" ()) +(declare-function org-reload "org" (&optional arg1)) +(declare-function org-remove-file "org" (&optional file)) +(declare-function org-resolve-clocks "org" (&optional only-dangling-p prompt-fn last-valid)) +(declare-function org-return "org" (&optional indent)) +(declare-function org-return-indent "org" ()) +(declare-function org-reveal "org" (&optional siblings)) +(declare-function org-schedule "org" (arg &optional time)) +(declare-function org-self-insert-command "org" (N)) +(declare-function org-set-effort "org" (&optional increment value)) +(declare-function org-set-property "org" (property value)) +(declare-function org-set-property-and-value "org" (use-last)) +(declare-function org-set-tags-command "org" (&optional arg)) +(declare-function org-shiftcontroldown "org" (&optional n)) +(declare-function org-shiftcontrolleft "org" ()) +(declare-function org-shiftcontrolright "org" ()) +(declare-function org-shiftcontrolup "org" (&optional n)) +(declare-function org-shiftdown "org" (&optional arg)) +(declare-function org-shiftleft "org" (&optional arg)) +(declare-function org-shiftmetadown "org" (&optional _arg)) +(declare-function org-shiftmetaleft "org" ()) +(declare-function org-shiftmetaright "org" ()) +(declare-function org-shiftmetaup "org" (&optional arg)) +(declare-function org-shiftright "org" (&optional arg)) +(declare-function org-shifttab "org" (&optional arg)) +(declare-function org-shiftup "org" (&optional arg)) +(declare-function org-show-all "org" (&optional types)) +(declare-function org-show-children "org" (&optional level)) +(declare-function org-show-subtree "org" ()) +(declare-function org-sort "org" (&optional with-case)) +(declare-function org-sparse-tree "org" (&optional arg type)) +(declare-function org-table-blank-field "org" ()) +(declare-function org-table-copy-down "org" (n)) +(declare-function org-table-create-or-convert-from-region "org" (arg)) +(declare-function org-table-create-with-table\.el "org-table" ()) +(declare-function org-table-edit-field "org" (arg)) +(declare-function org-table-eval-formula "org" (&optional arg equation suppress-align suppress-const suppress-store suppress-analysis)) +(declare-function org-table-field-info "org" (arg)) +(declare-function org-table-rotate-recalc-marks "org" (&optional newchar)) +(declare-function org-table-sum "org" (&optional beg end nlast)) +(declare-function org-table-toggle-coordinate-overlays "org" ()) +(declare-function org-table-toggle-formula-debugger "org" ()) +(declare-function org-time-stamp "org" (arg &optional inactive)) +(declare-function org-time-stamp-inactive "org" (&optional arg)) +(declare-function org-timer "org" (&optional restart no-insert)) +(declare-function org-timer-item "org" (&optional arg)) +(declare-function org-timer-pause-or-continue "org" (&optional stop)) +(declare-function org-timer-set-timer "org" (&optional opt)) +(declare-function org-timer-start "org" (&optional offset)) +(declare-function org-timer-stop "org" ()) +(declare-function org-todo "org" (&optional arg1)) +(declare-function org-toggle-archive-tag "org" (&optional find-done)) +(declare-function org-toggle-checkbox "org" (&optional toggle-presence)) +(declare-function org-toggle-comment "org" ()) +(declare-function org-toggle-fixed-width "org" ()) +(declare-function org-toggle-inline-images "org" (&optional include-linked)) +(declare-function org-toggle-latex-fragment "org" (&optional arg)) +(declare-function org-toggle-narrow-to-subtree "org" ()) +(declare-function org-toggle-ordered-property "org" ()) +(declare-function org-toggle-pretty-entities "org" ()) +(declare-function org-toggle-tags-groups "org" ()) +(declare-function org-toggle-time-stamp-overlays "org" ()) +(declare-function org-transpose-element "org" ()) +(declare-function org-transpose-words "org" ()) +(declare-function org-tree-to-indirect-buffer "org" (&optional arg)) +(declare-function org-up-element "org" ()) +(declare-function org-update-statistics-cookies "org" (all)) +(declare-function org-yank "org" (&optional arg)) +(declare-function orgtbl-ascii-plot "org-table" (&optional ask)) + + + +;;; Variables + +(defvar org-mode-map (make-sparse-keymap) + "Keymap fo Org mode.") + +(defcustom org-replace-disputed-keys nil + "Non-nil means use alternative key bindings for some keys. + +Org mode uses S- keys for changing timestamps and priorities. +These keys are also used by other packages like Shift Select mode, +CUA mode or Windmove. If you want to use Org mode together with +one of these other modes, or more generally if you would like to +move some Org mode commands to other keys, set this variable and +configure the keys with the variable `org-disputed-keys'. + +This option is only relevant at load-time of Org mode, and must be set +*before* org.el is loaded. Changing it requires a restart of Emacs to +become effective." + :group 'org-startup + :type 'boolean + :safe #'booleanp) + +(defcustom org-use-extra-keys nil + "Non-nil means use extra key sequence definitions for certain commands. +This happens automatically if `window-system' is nil. This +variable lets you do the same manually. You must set it before +loading Org." + :group 'org-startup + :type 'boolean + :safe #'booleanp) + +(defvaralias 'org-CUA-compatible 'org-replace-disputed-keys) + +(defcustom org-disputed-keys + '(([(shift up)] . [(meta p)]) + ([(shift down)] . [(meta n)]) + ([(shift left)] . [(meta -)]) + ([(shift right)] . [(meta +)]) + ([(control shift right)] . [(meta shift +)]) + ([(control shift left)] . [(meta shift -)])) + "Keys for which Org mode and other modes compete. +This is an alist, cars are the default keys, second element specifies +the alternative to use when `org-replace-disputed-keys' is t. + +Keys can be specified in any syntax supported by `define-key'. +The value of this option takes effect only at Org mode startup, +therefore you'll have to restart Emacs to apply it after changing." + :group 'org-startup + :type 'alist) + +(defcustom org-mouse-1-follows-link + (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t) + "Non-nil means mouse-1 on a link will follow the link. +A longer mouse click will still set point. Needs to be set +before org.el is loaded." + :group 'org-link-follow + :version "26.1" + :package-version '(Org . "8.3") + :type '(choice + (const :tag "A double click follows the link" double) + (const :tag "Unconditionally follow the link with mouse-1" t) + (integer :tag "mouse-1 click does not follow the link if longer than N ms" 450)) + :safe t) + +(defcustom org-tab-follows-link nil + "Non-nil means on links TAB will follow the link. +Needs to be set before Org is loaded. +This really should not be used, it does not make sense, and the +implementation is bad." + :group 'org-link-follow + :type 'boolean) + +(defcustom org-follow-link-hook nil + "Hook that is run after a link has been followed." + :group 'org-link-follow + :type 'hook) + +(defcustom org-return-follows-link nil + "Non-nil means on links RET will follow the link. +In tables, the special behavior of RET has precedence." + :group 'org-link-follow + :type 'boolean + :safe t) + + +;;; Functions + +;;;; Base functions +(defun org-key (key) + "Select key according to `org-replace-disputed-keys' and `org-disputed-keys'. +Or return the original if not disputed." + (when org-replace-disputed-keys + (let* ((nkey (key-description key)) + (x (cl-find-if (lambda (x) (equal (key-description (car x)) nkey)) + org-disputed-keys))) + (setq key (if x (cdr x) key)))) + key) + +(defun org-defkey (keymap key def) + "Define a key, possibly translated, as returned by `org-key'." + (define-key keymap (org-key key) def)) + +(defun org-remap (map &rest commands) + "In MAP, remap the functions given in COMMANDS. +COMMANDS is a list of alternating OLDDEF NEWDEF command names." + (let (new old) + (while commands + (setq old (pop commands) new (pop commands)) + (org-defkey map (vector 'remap old) new)))) + + +;;; Mouse map + +(defvar org-mouse-map (make-sparse-keymap)) +(org-defkey org-mouse-map [mouse-2] 'org-open-at-mouse) +(org-defkey org-mouse-map [mouse-3] 'org-find-file-at-mouse) + +(when org-mouse-1-follows-link + (org-defkey org-mouse-map [follow-link] 'mouse-face)) + +(when org-tab-follows-link + (org-defkey org-mouse-map (kbd "") #'org-open-at-point) + (org-defkey org-mouse-map (kbd "TAB") #'org-open-at-point)) + + +;;; Read date map + +(defvar org-read-date-minibuffer-local-map + (let* ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-map) + (org-defkey map (kbd ".") + (lambda () (interactive) + ;; Are we at the beginning of the prompt? + (if (looking-back "^[^:]+: " + (let ((inhibit-field-text-motion t)) + (line-beginning-position))) + (org-eval-in-calendar '(calendar-goto-today)) + (insert ".")))) + (org-defkey map (kbd "C-.") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-goto-today)))) + (org-defkey map (kbd "M-S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-month 1)))) + (org-defkey map (kbd "ESC S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-month 1)))) + (org-defkey map (kbd "M-S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-month 1)))) + (org-defkey map (kbd "ESC S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-month 1)))) + (org-defkey map (kbd "M-S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-year 1)))) + (org-defkey map (kbd "ESC S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-year 1)))) + (org-defkey map (kbd "M-S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-year 1)))) + (org-defkey map (kbd "ESC S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-year 1)))) + (org-defkey map (kbd "S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-week 1)))) + (org-defkey map (kbd "S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-week 1)))) + (org-defkey map (kbd "S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-day 1)))) + (org-defkey map (kbd "S-") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-day 1)))) + (org-defkey map (kbd "!") + (lambda () (interactive) + (org-eval-in-calendar '(diary-view-entries)) + (message ""))) + (org-defkey map (kbd ">") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-scroll-left 1)))) + (org-defkey map (kbd "<") + (lambda () (interactive) + (org-eval-in-calendar '(calendar-scroll-right 1)))) + (org-defkey map (kbd "C-v") + (lambda () (interactive) + (org-eval-in-calendar + '(calendar-scroll-left-three-months 1)))) + (org-defkey map (kbd "M-v") + (lambda () (interactive) + (org-eval-in-calendar + '(calendar-scroll-right-three-months 1)))) + map) + "Keymap for minibuffer commands when using `org-read-date'.") + + +;;; Global bindings + +;;;; Outline functions +(define-key org-mode-map [menu-bar headings] 'undefined) +(define-key org-mode-map [menu-bar hide] 'undefined) +(define-key org-mode-map [menu-bar show] 'undefined) + +(define-key org-mode-map [remap outline-mark-subtree] #'org-mark-subtree) +(define-key org-mode-map [remap outline-show-subtree] #'org-show-subtree) +(define-key org-mode-map [remap outline-forward-same-level] + #'org-forward-heading-same-level) +(define-key org-mode-map [remap outline-backward-same-level] + #'org-backward-heading-same-level) +(define-key org-mode-map [remap outline-show-branches] + #'org-kill-note-or-show-branches) +(define-key org-mode-map [remap outline-promote] #'org-promote-subtree) +(define-key org-mode-map [remap outline-demote] #'org-demote-subtree) +(define-key org-mode-map [remap outline-insert-heading] #'org-ctrl-c-ret) +(define-key org-mode-map [remap outline-next-visible-heading] + #'org-next-visible-heading) +(define-key org-mode-map [remap outline-previous-visible-heading] + #'org-previous-visible-heading) +(define-key org-mode-map [remap show-children] #'org-show-children) + +;;;; Make `C-c C-x' a prefix key +(org-defkey org-mode-map (kbd "C-c C-x") (make-sparse-keymap)) + +;;;; TAB key with modifiers +(org-defkey org-mode-map (kbd "C-i") #'org-cycle) +(org-defkey org-mode-map (kbd "") #'org-cycle) +(org-defkey org-mode-map (kbd "C-") #'org-force-cycle-archived) +(org-defkey org-mode-map (kbd "M-") #'pcomplete) +(org-defkey org-mode-map (kbd "ESC ") #'pcomplete) + +(org-defkey org-mode-map (kbd "") #'org-shifttab) +(org-defkey org-mode-map (kbd "S-") #'org-shifttab) +(define-key org-mode-map (kbd "") #'org-shifttab) + +;;;; RET key with modifiers +(org-defkey org-mode-map (kbd "S-") #'org-table-copy-down) +(org-defkey org-mode-map (kbd "M-S-") #'org-insert-todo-heading) +(org-defkey org-mode-map (kbd "ESC S-") #'org-insert-todo-heading) +(org-defkey org-mode-map (kbd "M-RET") #'org-meta-return) +(org-defkey org-mode-map (kbd "ESC RET") #'org-meta-return) + +;;;; Cursor keys with modifiers +(org-defkey org-mode-map (kbd "M-") #'org-metaleft) +(org-defkey org-mode-map (kbd "M-") #'org-metaright) +(org-defkey org-mode-map (kbd "ESC ") #'org-metaright) +(org-defkey org-mode-map (kbd "M-") #'org-metaup) +(org-defkey org-mode-map (kbd "ESC ") #'org-metaup) +(org-defkey org-mode-map (kbd "M-") #'org-metadown) +(org-defkey org-mode-map (kbd "ESC ") #'org-metadown) + +(org-defkey org-mode-map (kbd "C-M-S-") #'org-increase-number-at-point) +(org-defkey org-mode-map (kbd "C-M-S-") #'org-decrease-number-at-point) +(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetaleft) +(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetaleft) +(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetaright) +(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetaright) +(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetaup) +(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetaup) +(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetadown) +(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetadown) + +(org-defkey org-mode-map (kbd "S-") #'org-shiftup) +(org-defkey org-mode-map (kbd "S-") #'org-shiftdown) +(org-defkey org-mode-map (kbd "S-") #'org-shiftleft) +(org-defkey org-mode-map (kbd "S-") #'org-shiftright) + +(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontrolright) +(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontrolleft) +(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontrolup) +(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontroldown) + +;;;; Extra keys for TTY access. + +;; We only set them when really needed because otherwise the +;; menus don't show the simple keys + +(when (or org-use-extra-keys (not window-system)) + (org-defkey org-mode-map (kbd "C-c C-x c") #'org-table-copy-down) + (org-defkey org-mode-map (kbd "C-c C-x m") #'org-meta-return) + (org-defkey org-mode-map (kbd "C-c C-x M") #'org-insert-todo-heading) + (org-defkey org-mode-map (kbd "C-c C-x RET") #'org-meta-return) + (org-defkey org-mode-map (kbd "ESC RET") #'org-meta-return) + (org-defkey org-mode-map (kbd "ESC ") #'org-metaleft) + (org-defkey org-mode-map (kbd "C-c C-x l") #'org-metaleft) + (org-defkey org-mode-map (kbd "ESC ") #'org-metaright) + (org-defkey org-mode-map (kbd "C-c C-x r") #'org-metaright) + (org-defkey org-mode-map (kbd "C-c C-x u") #'org-metaup) + (org-defkey org-mode-map (kbd "C-c C-x d") #'org-metadown) + (org-defkey org-mode-map (kbd "C-c C-x L") #'org-shiftmetaleft) + (org-defkey org-mode-map (kbd "C-c C-x R") #'org-shiftmetaright) + (org-defkey org-mode-map (kbd "C-c C-x U") #'org-shiftmetaup) + (org-defkey org-mode-map (kbd "C-c C-x D") #'org-shiftmetadown) + (org-defkey org-mode-map (kbd "C-c ") #'org-shiftup) + (org-defkey org-mode-map (kbd "C-c ") #'org-shiftdown) + (org-defkey org-mode-map (kbd "C-c ") #'org-shiftleft) + (org-defkey org-mode-map (kbd "C-c ") #'org-shiftright) + (org-defkey org-mode-map (kbd "C-c C-x ") #'org-shiftcontrolright) + (org-defkey org-mode-map (kbd "C-c C-x ") #'org-shiftcontrolleft)) + +;;;; Narrow map +(org-defkey narrow-map "s" #'org-narrow-to-subtree) +(org-defkey narrow-map "b" #'org-narrow-to-block) +(org-defkey narrow-map "e" #'org-narrow-to-element) + +;;;; Remap usual Emacs bindings +(org-remap org-mode-map + 'self-insert-command 'org-self-insert-command + 'delete-char 'org-delete-char + 'delete-backward-char 'org-delete-backward-char + 'kill-line 'org-kill-line + 'open-line 'org-open-line + 'yank 'org-yank + 'comment-dwim 'org-comment-dwim + 'move-beginning-of-line 'org-beginning-of-line + 'move-end-of-line 'org-end-of-line + 'forward-paragraph 'org-forward-paragraph + 'backward-paragraph 'org-backward-paragraph + 'backward-sentence 'org-backward-sentence + 'forward-sentence 'org-forward-sentence + 'fill-paragraph 'org-fill-paragraph + 'delete-indentation 'org-delete-indentation + 'transpose-words 'org-transpose-words) + +;;;; All the other keys +(org-defkey org-mode-map (kbd "|") #'org-force-self-insert) +(org-defkey org-mode-map (kbd "C-c C-r") #'org-reveal) +(org-defkey org-mode-map (kbd "C-M-t") #'org-transpose-element) +(org-defkey org-mode-map (kbd "M-}") #'org-forward-element) +(org-defkey org-mode-map (kbd "ESC }") #'org-forward-element) +(org-defkey org-mode-map (kbd "M-{") #'org-backward-element) +(org-defkey org-mode-map (kbd "ESC {") #'org-backward-element) +(org-defkey org-mode-map (kbd "C-c C-^") #'org-up-element) +(org-defkey org-mode-map (kbd "C-c C-_") #'org-down-element) +(org-defkey org-mode-map (kbd "C-c C-f") #'org-forward-heading-same-level) +(org-defkey org-mode-map (kbd "C-c C-b") #'org-backward-heading-same-level) +(org-defkey org-mode-map (kbd "C-c M-f") #'org-next-block) +(org-defkey org-mode-map (kbd "C-c M-b") #'org-previous-block) +(org-defkey org-mode-map (kbd "C-c $") #'org-archive-subtree) +(org-defkey org-mode-map (kbd "C-c C-x C-s") #'org-archive-subtree) +(org-defkey org-mode-map (kbd "C-c C-x C-a") #'org-archive-subtree-default) +(org-defkey org-mode-map (kbd "C-c C-x d") #'org-insert-drawer) +(org-defkey org-mode-map (kbd "C-c C-x a") #'org-toggle-archive-tag) +(org-defkey org-mode-map (kbd "C-c C-x A") #'org-archive-to-archive-sibling) +(org-defkey org-mode-map (kbd "C-c C-x b") #'org-tree-to-indirect-buffer) +(org-defkey org-mode-map (kbd "C-c C-x q") #'org-toggle-tags-groups) +(org-defkey org-mode-map (kbd "C-c C-j") #'org-goto) +(org-defkey org-mode-map (kbd "C-c C-t") #'org-todo) +(org-defkey org-mode-map (kbd "C-c C-q") #'org-set-tags-command) +(org-defkey org-mode-map (kbd "C-c C-s") #'org-schedule) +(org-defkey org-mode-map (kbd "C-c C-d") #'org-deadline) +(org-defkey org-mode-map (kbd "C-c ;") #'org-toggle-comment) +(org-defkey org-mode-map (kbd "C-c C-w") #'org-refile) +(org-defkey org-mode-map (kbd "C-c M-w") #'org-copy) +(org-defkey org-mode-map (kbd "C-c /") #'org-sparse-tree) ;minor-mode reserved +(org-defkey org-mode-map (kbd "C-c \\") #'org-match-sparse-tree) ;minor-mode r. +(org-defkey org-mode-map (kbd "C-c RET") #'org-ctrl-c-ret) +(org-defkey org-mode-map (kbd "C-c C-x c") #'org-clone-subtree-with-time-shift) +(org-defkey org-mode-map (kbd "C-c C-x v") #'org-copy-visible) +(org-defkey org-mode-map (kbd "C-") #'org-insert-heading-respect-content) +(org-defkey org-mode-map (kbd "C-S-") #'org-insert-todo-heading-respect-content) +(org-defkey org-mode-map (kbd "C-c C-x C-n") #'org-next-link) +(org-defkey org-mode-map (kbd "C-c C-x C-p") #'org-previous-link) +(org-defkey org-mode-map (kbd "C-c C-l") #'org-insert-link) +(org-defkey org-mode-map (kbd "C-c M-l") #'org-insert-last-stored-link) +(org-defkey org-mode-map (kbd "C-c C-M-l") #'org-insert-all-links) +(org-defkey org-mode-map (kbd "C-c C-o") #'org-open-at-point) +(org-defkey org-mode-map (kbd "C-c %") #'org-mark-ring-push) +(org-defkey org-mode-map (kbd "C-c &") #'org-mark-ring-goto) +(org-defkey org-mode-map (kbd "C-c C-z") #'org-add-note) ;alternative binding +(org-defkey org-mode-map (kbd "C-c .") #'org-time-stamp) ;minor-mode reserved +(org-defkey org-mode-map (kbd "C-c !") #'org-time-stamp-inactive) ;minor-mode r. +(org-defkey org-mode-map (kbd "C-c ,") #'org-priority) ;minor-mode reserved +(org-defkey org-mode-map (kbd "C-c C-y") #'org-evaluate-time-range) +(org-defkey org-mode-map (kbd "C-c >") #'org-goto-calendar) +(org-defkey org-mode-map (kbd "C-c <") #'org-date-from-calendar) +(org-defkey org-mode-map (kbd "C-,") #'org-cycle-agenda-files) +(org-defkey org-mode-map (kbd "C-'") #'org-cycle-agenda-files) +(org-defkey org-mode-map (kbd "C-c [") #'org-agenda-file-to-front) +(org-defkey org-mode-map (kbd "C-c ]") #'org-remove-file) +(org-defkey org-mode-map (kbd "C-c C-x <") #'org-agenda-set-restriction-lock) +(org-defkey org-mode-map (kbd "C-c C-x >") #'org-agenda-remove-restriction-lock) +(org-defkey org-mode-map (kbd "C-c -") #'org-ctrl-c-minus) +(org-defkey org-mode-map (kbd "C-c *") #'org-ctrl-c-star) +(org-defkey org-mode-map (kbd "C-c TAB") #'org-ctrl-c-tab) +(org-defkey org-mode-map (kbd "C-c ^") #'org-sort) +(org-defkey org-mode-map (kbd "C-c C-c") #'org-ctrl-c-ctrl-c) +(org-defkey org-mode-map (kbd "C-c C-k") #'org-kill-note-or-show-branches) +(org-defkey org-mode-map (kbd "C-c #") #'org-update-statistics-cookies) +(org-defkey org-mode-map (kbd "RET") #'org-return) +(org-defkey org-mode-map (kbd "C-j") #'org-return-indent) +(org-defkey org-mode-map (kbd "C-c ?") #'org-table-field-info) +(org-defkey org-mode-map (kbd "C-c SPC") #'org-table-blank-field) +(org-defkey org-mode-map (kbd "C-c +") #'org-table-sum) +(org-defkey org-mode-map (kbd "C-c =") #'org-table-eval-formula) +(org-defkey org-mode-map (kbd "C-c '") #'org-edit-special) +(org-defkey org-mode-map (kbd "C-c `") #'org-table-edit-field) +(org-defkey org-mode-map (kbd "C-c \" a") #'orgtbl-ascii-plot) +(org-defkey org-mode-map (kbd "C-c \" g") #'org-plot/gnuplot) +(org-defkey org-mode-map (kbd "C-c |") #'org-table-create-or-convert-from-region) +(org-defkey org-mode-map (kbd "C-#") #'org-table-rotate-recalc-marks) +(org-defkey org-mode-map (kbd "C-c ~") #'org-table-create-with-table.el) +(org-defkey org-mode-map (kbd "C-c C-a") #'org-attach) +(org-defkey org-mode-map (kbd "C-c }") #'org-table-toggle-coordinate-overlays) +(org-defkey org-mode-map (kbd "C-c {") #'org-table-toggle-formula-debugger) +(org-defkey org-mode-map (kbd "C-c C-e") #'org-export-dispatch) +(org-defkey org-mode-map (kbd "C-c :") #'org-toggle-fixed-width) +(org-defkey org-mode-map (kbd "C-c C-x C-f") #'org-emphasize) +(org-defkey org-mode-map (kbd "C-c C-x f") #'org-footnote-action) +(org-defkey org-mode-map (kbd "C-c @") #'org-mark-subtree) +(org-defkey org-mode-map (kbd "M-h") #'org-mark-element) +(org-defkey org-mode-map (kbd "ESC h") #'org-mark-element) +(org-defkey org-mode-map (kbd "C-c C-*") #'org-list-make-subtree) +(org-defkey org-mode-map (kbd "C-c C-x C-w") #'org-cut-special) +(org-defkey org-mode-map (kbd "C-c C-x M-w") #'org-copy-special) +(org-defkey org-mode-map (kbd "C-c C-x C-y") #'org-paste-special) +(org-defkey org-mode-map (kbd "C-c C-x C-t") #'org-toggle-time-stamp-overlays) +(org-defkey org-mode-map (kbd "C-c C-x C-i") #'org-clock-in) +(org-defkey org-mode-map (kbd "C-c C-x C-x") #'org-clock-in-last) +(org-defkey org-mode-map (kbd "C-c C-x C-z") #'org-resolve-clocks) +(org-defkey org-mode-map (kbd "C-c C-x C-o") #'org-clock-out) +(org-defkey org-mode-map (kbd "C-c C-x C-j") #'org-clock-goto) +(org-defkey org-mode-map (kbd "C-c C-x C-q") #'org-clock-cancel) +(org-defkey org-mode-map (kbd "C-c C-x C-d") #'org-clock-display) +(org-defkey org-mode-map (kbd "C-c C-x C-r") #'org-clock-report) +(org-defkey org-mode-map (kbd "C-c C-x C-u") #'org-dblock-update) +(org-defkey org-mode-map (kbd "C-c C-x C-l") #'org-toggle-latex-fragment) +(org-defkey org-mode-map (kbd "C-c C-x C-v") #'org-toggle-inline-images) +(org-defkey org-mode-map (kbd "C-c C-x C-M-v") #'org-redisplay-inline-images) +(org-defkey org-mode-map (kbd "C-c C-x \\") #'org-toggle-pretty-entities) +(org-defkey org-mode-map (kbd "C-c C-x C-b") #'org-toggle-checkbox) +(org-defkey org-mode-map (kbd "C-c C-x p") #'org-set-property) +(org-defkey org-mode-map (kbd "C-c C-x P") #'org-set-property-and-value) +(org-defkey org-mode-map (kbd "C-c C-x e") #'org-set-effort) +(org-defkey org-mode-map (kbd "C-c C-x E") #'org-inc-effort) +(org-defkey org-mode-map (kbd "C-c C-x o") #'org-toggle-ordered-property) +(org-defkey org-mode-map (kbd "C-c C-x i") #'org-columns-insert-dblock) +(org-defkey org-mode-map (kbd "C-c C-,") #'org-insert-structure-template) +(org-defkey org-mode-map (kbd "C-c C-x .") #'org-timer) +(org-defkey org-mode-map (kbd "C-c C-x -") #'org-timer-item) +(org-defkey org-mode-map (kbd "C-c C-x 0") #'org-timer-start) +(org-defkey org-mode-map (kbd "C-c C-x _") #'org-timer-stop) +(org-defkey org-mode-map (kbd "C-c C-x ;") #'org-timer-set-timer) +(org-defkey org-mode-map (kbd "C-c C-x ,") #'org-timer-pause-or-continue) +(org-defkey org-mode-map (kbd "C-c C-x C-c") #'org-columns) +(org-defkey org-mode-map (kbd "C-c C-x !") #'org-reload) +(org-defkey org-mode-map (kbd "C-c C-x g") #'org-feed-update-all) +(org-defkey org-mode-map (kbd "C-c C-x G") #'org-feed-goto-inbox) +(org-defkey org-mode-map (kbd "C-c C-x [") #'org-reftex-citation) +(org-defkey org-mode-map (kbd "C-c C-x I") #'org-info-find-node) + + +;;; Speed keys + +(defcustom org-use-speed-commands nil + "Non-nil means activate single letter commands at beginning of a headline. +This may also be a function to test for appropriate locations where speed +commands should be active. + +For example, to activate speed commands when the point is on any +star at the beginning of the headline, you can do this: + + (setq org-use-speed-commands + (lambda () (and (looking-at org-outline-regexp) (looking-back \"^\\**\"))))" + :group 'org-structure + :type '(choice + (const :tag "Never" nil) + (const :tag "At beginning of headline stars" t) + (function))) + +(defcustom org-speed-commands-user nil + "Alist of additional speed commands. +This list will be checked before `org-speed-commands-default' +when the variable `org-use-speed-commands' is non-nil +and when the cursor is at the beginning of a headline. +The car of each entry is a string with a single letter, which must +be assigned to `self-insert-command' in the global map. +The cdr is either a command to be called interactively, a function +to be called, or a form to be evaluated. +An entry that is just a list with a single string will be interpreted +as a descriptive headline that will be added when listing the speed +commands in the Help buffer using the `?' speed command." + :group 'org-structure + :type '(repeat :value ("k" . ignore) + (choice :value ("k" . ignore) + (list :tag "Descriptive Headline" (string :tag "Headline")) + (cons :tag "Letter and Command" + (string :tag "Command letter") + (choice + (function) + (sexp)))))) + +(defcustom org-speed-command-hook + '(org-speed-command-activate org-babel-speed-command-activate) + "Hook for activating speed commands at strategic locations. +Hook functions are called in sequence until a valid handler is +found. + +Each hook takes a single argument, a user-pressed command key +which is also a `self-insert-command' from the global map. + +Within the hook, examine the cursor position and the command key +and return nil or a valid handler as appropriate. Handler could +be one of an interactive command, a function, or a form. + +Set `org-use-speed-commands' to non-nil value to enable this +hook. The default setting is `org-speed-command-activate'." + :group 'org-structure + :version "24.1" + :type 'hook) + +(defconst org-speed-commands-default + '(("Outline Navigation") + ("n" . (org-speed-move-safe 'org-next-visible-heading)) + ("p" . (org-speed-move-safe 'org-previous-visible-heading)) + ("f" . (org-speed-move-safe 'org-forward-heading-same-level)) + ("b" . (org-speed-move-safe 'org-backward-heading-same-level)) + ("F" . org-next-block) + ("B" . org-previous-block) + ("u" . (org-speed-move-safe 'outline-up-heading)) + ("j" . org-goto) + ("g" . (org-refile t)) + ("Outline Visibility") + ("c" . org-cycle) + ("C" . org-shifttab) + (" " . org-display-outline-path) + ("s" . org-toggle-narrow-to-subtree) + ("k" . org-cut-subtree) + ("=" . org-columns) + ("Outline Structure Editing") + ("U" . org-metaup) + ("D" . org-metadown) + ("r" . org-metaright) + ("l" . org-metaleft) + ("R" . org-shiftmetaright) + ("L" . org-shiftmetaleft) + ("i" . (progn (forward-char 1) (call-interactively + 'org-insert-heading-respect-content))) + ("^" . org-sort) + ("w" . org-refile) + ("a" . org-archive-subtree-default-with-confirmation) + ("@" . org-mark-subtree) + ("#" . org-toggle-comment) + ("Clock Commands") + ("I" . org-clock-in) + ("O" . org-clock-out) + ("Meta Data Editing") + ("t" . org-todo) + ("," . (org-priority)) + ("0" . (org-priority ?\ )) + ("1" . (org-priority ?A)) + ("2" . (org-priority ?B)) + ("3" . (org-priority ?C)) + (":" . org-set-tags-command) + ("e" . org-set-effort) + ("E" . org-inc-effort) + ("W" . (lambda(m) (interactive "sMinutes before warning: ") + (org-entry-put (point) "APPT_WARNTIME" m))) + ("Agenda Views etc") + ("v" . org-agenda) + ("/" . org-sparse-tree) + ("Misc") + ("o" . org-open-at-point) + ("?" . org-speed-command-help) + ("<" . (org-agenda-set-restriction-lock 'subtree)) + (">" . (org-agenda-remove-restriction-lock))) + "The default speed commands.") + +(defun org-print-speed-command (e) + (if (> (length (car e)) 1) + (progn + (princ "\n") + (princ (car e)) + (princ "\n") + (princ (make-string (length (car e)) ?-)) + (princ "\n")) + (princ (car e)) + (princ " ") + (if (symbolp (cdr e)) + (princ (symbol-name (cdr e))) + (prin1 (cdr e))) + (princ "\n"))) + +(defun org-speed-command-help () + "Show the available speed commands." + (interactive) + (unless org-use-speed-commands + (user-error "Speed commands are not activated, customize `org-use-speed-commands'")) + (with-output-to-temp-buffer "*Help*" + (princ "User-defined Speed commands\n===========================\n") + (mapc #'org-print-speed-command org-speed-commands-user) + (princ "\n") + (princ "Built-in Speed commands\n=======================\n") + (mapc #'org-print-speed-command org-speed-commands-default)) + (with-current-buffer "*Help*" + (setq truncate-lines t))) + +(defun org-speed-move-safe (cmd) + "Execute CMD, but make sure that the cursor always ends up in a headline. +If not, return to the original position and throw an error." + (interactive) + (let ((pos (point))) + (call-interactively cmd) + (unless (and (bolp) (org-at-heading-p)) + (goto-char pos) + (error "Boundary reached while executing %s" cmd)))) + +(defun org-speed-command-activate (keys) + "Hook for activating single-letter speed commands. +`org-speed-commands-default' specifies a minimal command set. +Use `org-speed-commands-user' for further customization." + (when (or (and (bolp) (looking-at org-outline-regexp)) + (and (functionp org-use-speed-commands) + (funcall org-use-speed-commands))) + (cdr (assoc keys (append org-speed-commands-user + org-speed-commands-default))))) + + +;;; Babel speed keys + +(defvar org-babel-key-prefix "\C-c\C-v" + "The key prefix for Babel interactive key-bindings. +See `org-babel-key-bindings' for the list of interactive Babel +functions which are assigned key bindings, and see +`org-babel-map' for the actual babel keymap.") + +(defvar org-babel-map (make-sparse-keymap) + "The keymap for interactive Babel functions.") + +(defvar org-babel-key-bindings + '(("p" . org-babel-previous-src-block) + ("\C-p" . org-babel-previous-src-block) + ("n" . org-babel-next-src-block) + ("\C-n" . org-babel-next-src-block) + ("e" . org-babel-execute-maybe) + ("\C-e" . org-babel-execute-maybe) + ("o" . org-babel-open-src-block-result) + ("\C-o" . org-babel-open-src-block-result) + ("\C-v" . org-babel-expand-src-block) + ("v" . org-babel-expand-src-block) + ("u" . org-babel-goto-src-block-head) + ("\C-u" . org-babel-goto-src-block-head) + ("g" . org-babel-goto-named-src-block) + ("r" . org-babel-goto-named-result) + ("\C-r" . org-babel-goto-named-result) + ("\C-b" . org-babel-execute-buffer) + ("b" . org-babel-execute-buffer) + ("\C-s" . org-babel-execute-subtree) + ("s" . org-babel-execute-subtree) + ("\C-d" . org-babel-demarcate-block) + ("d" . org-babel-demarcate-block) + ("\C-t" . org-babel-tangle) + ("t" . org-babel-tangle) + ("\C-f" . org-babel-tangle-file) + ("f" . org-babel-tangle-file) + ("\C-c" . org-babel-check-src-block) + ("c" . org-babel-check-src-block) + ("\C-j" . org-babel-insert-header-arg) + ("j" . org-babel-insert-header-arg) + ("\C-l" . org-babel-load-in-session) + ("l" . org-babel-load-in-session) + ("\C-i" . org-babel-lob-ingest) + ("i" . org-babel-lob-ingest) + ("\C-I" . org-babel-view-src-block-info) + ("I" . org-babel-view-src-block-info) + ("\C-z" . org-babel-switch-to-session) + ("z" . org-babel-switch-to-session-with-code) + ("\C-a" . org-babel-sha1-hash) + ("a" . org-babel-sha1-hash) + ("h" . org-babel-describe-bindings) + ("\C-x" . org-babel-do-key-sequence-in-edit-buffer) + ("x" . org-babel-do-key-sequence-in-edit-buffer) + ("k" . org-babel-remove-result-one-or-many) + ("\C-\M-h" . org-babel-mark-block)) + "Alist of key bindings and interactive Babel functions. +This list associates interactive Babel functions +with keys. Each element of this list will add an entry to the +`org-babel-map' using the letter key which is the `car' of the +a-list placed behind the generic `org-babel-key-prefix'.") + +(define-key org-mode-map org-babel-key-prefix org-babel-map) +(pcase-dolist (`(,key . ,def) org-babel-key-bindings) + (define-key org-babel-map key def)) + +(defun org-babel-speed-command-activate (keys) + "Hook for activating single-letter code block commands." + (when (and (bolp) + (let ((case-fold-search t)) (looking-at "[ \t]*#\\+begin_src")) + (eq 'src-block (org-element-type (org-element-at-point)))) + (cdr (assoc keys org-babel-key-bindings)))) + +;;;###autoload +(defun org-babel-describe-bindings () + "Describe all keybindings behind `org-babel-key-prefix'." + (interactive) + (describe-bindings org-babel-key-prefix)) + + +(provide 'org-keys) +;;; org-keys.el ends here diff --git a/lisp/org-src.el b/lisp/org-src.el index 9c462b7e7..2584a3f4a 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -32,10 +32,10 @@ ;;; Code: (require 'cl-lib) +(require 'ob-comint) (require 'org-macs) (require 'org-compat) -(require 'ob-keys) -(require 'ob-comint) +(require 'org-keys) (declare-function org-element-at-point "org-element" ()) (declare-function org-element-class "org-element" (datum &optional parent)) diff --git a/lisp/org.el b/lisp/org.el index 6852deeb9..11d0514c2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -92,6 +92,7 @@ (eval-and-compile (require 'org-macs)) (require 'org-compat) +(require 'org-keys) ;; `org-outline-regexp' ought to be a defconst but is let-bound in ;; some places -- e.g. see the macro `org-with-limited-levels'. @@ -223,6 +224,7 @@ Stars are put in group 1 and the trimmed body in group 2.") (defvar ffap-url-regexp) (defvar org-element-paragraph-separate) (defvar org-indent-indentation-per-level) +(defvar org-table-auto-blank-field) ;; load languages based on value of `org-babel-load-languages' (defvar org-babel-load-languages) @@ -1116,63 +1118,6 @@ has been set." :group 'org-startup :type 'boolean) -(defcustom org-replace-disputed-keys nil - "Non-nil means use alternative key bindings for some keys. - -Org mode uses S- keys for changing timestamps and priorities. -These keys are also used by other packages like Shift Select mode, -CUA mode or Windmove. If you want to use Org mode together with -one of these other modes, or more generally if you would like to -move some Org mode commands to other keys, set this variable and -configure the keys with the variable `org-disputed-keys'. - -This option is only relevant at load-time of Org mode, and must be set -*before* org.el is loaded. Changing it requires a restart of Emacs to -become effective." - :group 'org-startup - :type 'boolean) - -(defcustom org-use-extra-keys nil - "Non-nil means use extra key sequence definitions for certain commands. -This happens automatically if `window-system' is nil. This -variable lets you do the same manually. You must set it before -loading Org." - :group 'org-startup - :type 'boolean) - -(defvaralias 'org-CUA-compatible 'org-replace-disputed-keys) - -(defcustom org-disputed-keys - '(([(shift up)] . [(meta p)]) - ([(shift down)] . [(meta n)]) - ([(shift left)] . [(meta -)]) - ([(shift right)] . [(meta +)]) - ([(control shift right)] . [(meta shift +)]) - ([(control shift left)] . [(meta shift -)])) - "Keys for which Org mode and other modes compete. -This is an alist, cars are the default keys, second element specifies -the alternative to use when `org-replace-disputed-keys' is t. - -Keys can be specified in any syntax supported by `define-key'. -The value of this option takes effect only at Org mode startup, -therefore you'll have to restart Emacs to apply it after changing." - :group 'org-startup - :type 'alist) - -(defun org-key (key) - "Select key according to `org-replace-disputed-keys' and `org-disputed-keys'. -Or return the original if not disputed." - (when org-replace-disputed-keys - (let* ((nkey (key-description key)) - (x (cl-find-if (lambda (x) (equal (key-description (car x)) nkey)) - org-disputed-keys))) - (setq key (if x (cdr x) key)))) - key) - -(defun org-defkey (keymap key def) - "Define a key, possibly translated, as returned by `org-key'." - (define-key keymap (org-key key) def)) - (defcustom org-ellipsis nil "The ellipsis to use in the Org mode outline. @@ -1310,44 +1255,6 @@ new-frame Make a new frame each time. Note that in this case (const :tag "Each time a new frame" new-frame) (const :tag "One dedicated frame" dedicated-frame))) -(defcustom org-use-speed-commands nil - "Non-nil means activate single letter commands at beginning of a headline. -This may also be a function to test for appropriate locations where speed -commands should be active. - -For example, to activate speed commands when the point is on any -star at the beginning of the headline, you can do this: - - (setq org-use-speed-commands - (lambda () (and (looking-at org-outline-regexp) (looking-back \"^\\**\"))))" - :group 'org-structure - :type '(choice - (const :tag "Never" nil) - (const :tag "At beginning of headline stars" t) - (function))) - -(defcustom org-speed-commands-user nil - "Alist of additional speed commands. -This list will be checked before `org-speed-commands-default' -when the variable `org-use-speed-commands' is non-nil -and when the cursor is at the beginning of a headline. -The car of each entry is a string with a single letter, which must -be assigned to `self-insert-command' in the global map. -The cdr is either a command to be called interactively, a function -to be called, or a form to be evaluated. -An entry that is just a list with a single string will be interpreted -as a descriptive headline that will be added when listing the speed -commands in the Help buffer using the `?' speed command." - :group 'org-structure - :type '(repeat :value ("k" . ignore) - (choice :value ("k" . ignore) - (list :tag "Descriptive Headline" (string :tag "Headline")) - (cons :tag "Letter and Command" - (string :tag "Command letter") - (choice - (function) - (sexp)))))) - (defcustom org-bookmark-names-plist '(:last-capture "org-capture-last-stored" :last-refile "org-refile-last-stored" @@ -2051,38 +1958,6 @@ links created by planner." :group 'org-link-follow :type '(choice (const nil) (function))) -(defcustom org-follow-link-hook nil - "Hook that is run after a link has been followed." - :group 'org-link-follow - :type 'hook) - -(defcustom org-tab-follows-link nil - "Non-nil means on links TAB will follow the link. -Needs to be set before org.el is loaded. -This really should not be used, it does not make sense, and the -implementation is bad." - :group 'org-link-follow - :type 'boolean) - -(defcustom org-return-follows-link nil - "Non-nil means on links RET will follow the link. -In tables, the special behavior of RET has precedence." - :group 'org-link-follow - :type 'boolean) - -(defcustom org-mouse-1-follows-link - (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t) - "Non-nil means mouse-1 on a link will follow the link. -A longer mouse click will still set point. Needs to be set -before org.el is loaded." - :group 'org-link-follow - :version "26.1" - :package-version '(Org . "8.3") - :type '(choice - (const :tag "A double click follows the link" double) - (const :tag "Unconditionally follow the link with mouse-1" t) - (integer :tag "mouse-1 click does not follow the link if longer than N ms" 450))) - (defcustom org-mark-ring-length 4 "Number of different positions to be recorded in the ring. Changing this requires a restart of Emacs to work correctly." @@ -5451,15 +5326,6 @@ can be exported as a structured ASCII or HTML file. The following commands are available: \\{org-mode-map}" - - ;; Get rid of Outline menus, they are not needed - ;; Need to do this here because define-derived-mode sets up - ;; the keymap so late. Still, it is a waste to call this each time - ;; we switch another buffer into Org mode. - (define-key org-mode-map [menu-bar headings] 'undefined) - (define-key org-mode-map [menu-bar hide] 'undefined) - (define-key org-mode-map [menu-bar show] 'undefined) - (org-load-modules-maybe) (org-install-agenda-files-menu) (when org-descriptive-links (add-to-invisibility-spec '(org-link))) @@ -5639,15 +5505,6 @@ the rounding returns a past time." ;;;; Font-Lock stuff, including the activators -(defvar org-mouse-map (make-sparse-keymap)) -(org-defkey org-mouse-map [mouse-2] 'org-open-at-mouse) -(org-defkey org-mouse-map [mouse-3] 'org-find-file-at-mouse) -(when org-mouse-1-follows-link - (org-defkey org-mouse-map [follow-link] 'mouse-face)) -(when org-tab-follows-link - (org-defkey org-mouse-map (kbd "") #'org-open-at-point) - (org-defkey org-mouse-map (kbd "TAB") #'org-open-at-point)) - (require 'font-lock) (defconst org-non-link-chars "]\t\n\r<>") @@ -16109,78 +15966,6 @@ with the current time without prompting the user." (defvar org-read-date-analyze-futurep nil) (defvar org-read-date-analyze-forced-year nil) (defvar org-read-date-inactive) - -(defvar org-read-date-minibuffer-local-map - (let* ((map (make-sparse-keymap))) - (set-keymap-parent map minibuffer-local-map) - (org-defkey map (kbd ".") - (lambda () (interactive) - ;; Are we at the beginning of the prompt? - (if (looking-back "^[^:]+: " - (let ((inhibit-field-text-motion t)) - (line-beginning-position))) - (org-eval-in-calendar '(calendar-goto-today)) - (insert ".")))) - (org-defkey map (kbd "C-.") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-goto-today)))) - (org-defkey map (kbd "M-S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-month 1)))) - (org-defkey map (kbd "ESC S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-month 1)))) - (org-defkey map (kbd "M-S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-month 1)))) - (org-defkey map (kbd "ESC S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-month 1)))) - (org-defkey map (kbd "M-S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-year 1)))) - (org-defkey map (kbd "ESC S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-year 1)))) - (org-defkey map (kbd "M-S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-year 1)))) - (org-defkey map (kbd "ESC S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-year 1)))) - (org-defkey map (kbd "S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-week 1)))) - (org-defkey map (kbd "S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-week 1)))) - (org-defkey map (kbd "S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-day 1)))) - (org-defkey map (kbd "S-") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-day 1)))) - (org-defkey map (kbd "!") - (lambda () (interactive) - (org-eval-in-calendar '(diary-view-entries)) - (message ""))) - (org-defkey map (kbd ">") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-scroll-left 1)))) - (org-defkey map (kbd "<") - (lambda () (interactive) - (org-eval-in-calendar '(calendar-scroll-right 1)))) - (org-defkey map (kbd "C-v") - (lambda () (interactive) - (org-eval-in-calendar - '(calendar-scroll-left-three-months 1)))) - (org-defkey map (kbd "M-v") - (lambda () (interactive) - (org-eval-in-calendar - '(calendar-scroll-right-three-months 1)))) - map) - "Keymap for minibuffer commands when using `org-read-date'.") - (defvar org-def) (defvar org-defdecode) (defvar org-with-time) @@ -18844,410 +18629,9 @@ boundaries." (mapc #'delete-overlay org-inline-image-overlays) (setq org-inline-image-overlays nil)) - -;;; Key bindings - -(defun org-remap (map &rest commands) - "In MAP, remap the functions given in COMMANDS. -COMMANDS is a list of alternating OLDDEF NEWDEF command names." - (let (new old) - (while commands - (setq old (pop commands) new (pop commands)) - (org-defkey map (vector 'remap old) new)))) - -;;;; Outline functions that can be remapped in Org -(define-key org-mode-map [remap outline-mark-subtree] #'org-mark-subtree) -(define-key org-mode-map [remap outline-show-subtree] #'org-show-subtree) -(define-key org-mode-map [remap outline-forward-same-level] - #'org-forward-heading-same-level) -(define-key org-mode-map [remap outline-backward-same-level] - #'org-backward-heading-same-level) -(define-key org-mode-map [remap outline-show-branches] - #'org-kill-note-or-show-branches) -(define-key org-mode-map [remap outline-promote] #'org-promote-subtree) -(define-key org-mode-map [remap outline-demote] #'org-demote-subtree) -(define-key org-mode-map [remap outline-insert-heading] #'org-ctrl-c-ret) -(define-key org-mode-map [remap outline-next-visible-heading] - #'org-next-visible-heading) -(define-key org-mode-map [remap outline-previous-visible-heading] - #'org-previous-visible-heading) -(define-key org-mode-map [remap show-children] #'org-show-children) - -;;;; Make `C-c C-x' a prefix key -(org-defkey org-mode-map (kbd "C-c C-x") (make-sparse-keymap)) - -;;;; TAB key with modifiers -(org-defkey org-mode-map (kbd "C-i") #'org-cycle) -(org-defkey org-mode-map (kbd "") #'org-cycle) -(org-defkey org-mode-map (kbd "C-") #'org-force-cycle-archived) -(org-defkey org-mode-map (kbd "M-") #'pcomplete) -(org-defkey org-mode-map (kbd "ESC ") #'pcomplete) - -(org-defkey org-mode-map (kbd "") #'org-shifttab) -(org-defkey org-mode-map (kbd "S-") #'org-shifttab) -(define-key org-mode-map (kbd "") #'org-shifttab) - -;;;; RET key with modifiers -(org-defkey org-mode-map (kbd "S-") #'org-table-copy-down) -(org-defkey org-mode-map (kbd "M-S-") #'org-insert-todo-heading) -(org-defkey org-mode-map (kbd "ESC S-") #'org-insert-todo-heading) -(org-defkey org-mode-map (kbd "M-RET") #'org-meta-return) -(org-defkey org-mode-map (kbd "ESC RET") #'org-meta-return) - -;;;; Cursor keys with modifiers -(org-defkey org-mode-map (kbd "M-") #'org-metaleft) -(org-defkey org-mode-map (kbd "M-") #'org-metaright) -(org-defkey org-mode-map (kbd "ESC ") #'org-metaright) -(org-defkey org-mode-map (kbd "M-") #'org-metaup) -(org-defkey org-mode-map (kbd "ESC ") #'org-metaup) -(org-defkey org-mode-map (kbd "M-") #'org-metadown) -(org-defkey org-mode-map (kbd "ESC ") #'org-metadown) - -(org-defkey org-mode-map (kbd "C-M-S-") #'org-increase-number-at-point) -(org-defkey org-mode-map (kbd "C-M-S-") #'org-decrease-number-at-point) -(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetaleft) -(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetaleft) -(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetaright) -(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetaright) -(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetaup) -(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetaup) -(org-defkey org-mode-map (kbd "M-S-") #'org-shiftmetadown) -(org-defkey org-mode-map (kbd "ESC S-") #'org-shiftmetadown) - -(org-defkey org-mode-map (kbd "S-") #'org-shiftup) -(org-defkey org-mode-map (kbd "S-") #'org-shiftdown) -(org-defkey org-mode-map (kbd "S-") #'org-shiftleft) -(org-defkey org-mode-map (kbd "S-") #'org-shiftright) - -(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontrolright) -(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontrolleft) -(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontrolup) -(org-defkey org-mode-map (kbd "C-S-") #'org-shiftcontroldown) - -;;;; Babel keys -(define-key org-mode-map org-babel-key-prefix org-babel-map) -(pcase-dolist (`(,key . ,def) org-babel-key-bindings) - (define-key org-babel-map key def)) - -;;;; Extra keys for TTY access. - -;; We only set them when really needed because otherwise the -;; menus don't show the simple keys - -(when (or org-use-extra-keys (not window-system)) - (org-defkey org-mode-map (kbd "C-c C-x c") #'org-table-copy-down) - (org-defkey org-mode-map (kbd "C-c C-x m") #'org-meta-return) - (org-defkey org-mode-map (kbd "C-c C-x M") #'org-insert-todo-heading) - (org-defkey org-mode-map (kbd "C-c C-x RET") #'org-meta-return) - (org-defkey org-mode-map (kbd "ESC RET") #'org-meta-return) - (org-defkey org-mode-map (kbd "ESC ") #'org-metaleft) - (org-defkey org-mode-map (kbd "C-c C-x l") #'org-metaleft) - (org-defkey org-mode-map (kbd "ESC ") #'org-metaright) - (org-defkey org-mode-map (kbd "C-c C-x r") #'org-metaright) - (org-defkey org-mode-map (kbd "C-c C-x u") #'org-metaup) - (org-defkey org-mode-map (kbd "C-c C-x d") #'org-metadown) - (org-defkey org-mode-map (kbd "C-c C-x L") #'org-shiftmetaleft) - (org-defkey org-mode-map (kbd "C-c C-x R") #'org-shiftmetaright) - (org-defkey org-mode-map (kbd "C-c C-x U") #'org-shiftmetaup) - (org-defkey org-mode-map (kbd "C-c C-x D") #'org-shiftmetadown) - (org-defkey org-mode-map (kbd "C-c ") #'org-shiftup) - (org-defkey org-mode-map (kbd "C-c ") #'org-shiftdown) - (org-defkey org-mode-map (kbd "C-c ") #'org-shiftleft) - (org-defkey org-mode-map (kbd "C-c ") #'org-shiftright) - (org-defkey org-mode-map (kbd "C-c C-x ") #'org-shiftcontrolright) - (org-defkey org-mode-map (kbd "C-c C-x ") #'org-shiftcontrolleft)) - -;;;; Narrow map -(org-defkey narrow-map "s" #'org-narrow-to-subtree) -(org-defkey narrow-map "b" #'org-narrow-to-block) -(org-defkey narrow-map "e" #'org-narrow-to-element) - -;;;; Remap usual Emacs bindings -(org-remap org-mode-map - 'self-insert-command 'org-self-insert-command - 'delete-char 'org-delete-char - 'delete-backward-char 'org-delete-backward-char - 'kill-line 'org-kill-line - 'open-line 'org-open-line - 'yank 'org-yank - 'comment-dwim 'org-comment-dwim - 'move-beginning-of-line 'org-beginning-of-line - 'move-end-of-line 'org-end-of-line - 'forward-paragraph 'org-forward-paragraph - 'backward-paragraph 'org-backward-paragraph - 'backward-sentence 'org-backward-sentence - 'forward-sentence 'org-forward-sentence - 'fill-paragraph 'org-fill-paragraph - 'delete-indentation 'org-delete-indentation - 'transpose-words 'org-transpose-words) - -;;;; All the other keys -(org-defkey org-mode-map (kbd "|") #'org-force-self-insert) -(org-defkey org-mode-map (kbd "C-c C-r") #'org-reveal) -(org-defkey org-mode-map (kbd "C-M-t") #'org-transpose-element) -(org-defkey org-mode-map (kbd "M-}") #'org-forward-element) -(org-defkey org-mode-map (kbd "ESC }") #'org-forward-element) -(org-defkey org-mode-map (kbd "M-{") #'org-backward-element) -(org-defkey org-mode-map (kbd "ESC {") #'org-backward-element) -(org-defkey org-mode-map (kbd "C-c C-^") #'org-up-element) -(org-defkey org-mode-map (kbd "C-c C-_") #'org-down-element) -(org-defkey org-mode-map (kbd "C-c C-f") #'org-forward-heading-same-level) -(org-defkey org-mode-map (kbd "C-c C-b") #'org-backward-heading-same-level) -(org-defkey org-mode-map (kbd "C-c M-f") #'org-next-block) -(org-defkey org-mode-map (kbd "C-c M-b") #'org-previous-block) -(org-defkey org-mode-map (kbd "C-c $") #'org-archive-subtree) -(org-defkey org-mode-map (kbd "C-c C-x C-s") #'org-archive-subtree) -(org-defkey org-mode-map (kbd "C-c C-x C-a") #'org-archive-subtree-default) -(org-defkey org-mode-map (kbd "C-c C-x d") #'org-insert-drawer) -(org-defkey org-mode-map (kbd "C-c C-x a") #'org-toggle-archive-tag) -(org-defkey org-mode-map (kbd "C-c C-x A") #'org-archive-to-archive-sibling) -(org-defkey org-mode-map (kbd "C-c C-x b") #'org-tree-to-indirect-buffer) -(org-defkey org-mode-map (kbd "C-c C-x q") #'org-toggle-tags-groups) -(org-defkey org-mode-map (kbd "C-c C-j") #'org-goto) -(org-defkey org-mode-map (kbd "C-c C-t") #'org-todo) -(org-defkey org-mode-map (kbd "C-c C-q") #'org-set-tags-command) -(org-defkey org-mode-map (kbd "C-c C-s") #'org-schedule) -(org-defkey org-mode-map (kbd "C-c C-d") #'org-deadline) -(org-defkey org-mode-map (kbd "C-c ;") #'org-toggle-comment) -(org-defkey org-mode-map (kbd "C-c C-w") #'org-refile) -(org-defkey org-mode-map (kbd "C-c M-w") #'org-copy) -(org-defkey org-mode-map (kbd "C-c /") #'org-sparse-tree) ;minor-mode reserved -(org-defkey org-mode-map (kbd "C-c \\") #'org-match-sparse-tree) ;minor-mode r. -(org-defkey org-mode-map (kbd "C-c RET") #'org-ctrl-c-ret) -(org-defkey org-mode-map (kbd "C-c C-x c") #'org-clone-subtree-with-time-shift) -(org-defkey org-mode-map (kbd "C-c C-x v") #'org-copy-visible) -(org-defkey org-mode-map (kbd "C-") #'org-insert-heading-respect-content) -(org-defkey org-mode-map (kbd "C-S-") #'org-insert-todo-heading-respect-content) -(org-defkey org-mode-map (kbd "C-c C-x C-n") #'org-next-link) -(org-defkey org-mode-map (kbd "C-c C-x C-p") #'org-previous-link) -(org-defkey org-mode-map (kbd "C-c C-l") #'org-insert-link) -(org-defkey org-mode-map (kbd "C-c M-l") #'org-insert-last-stored-link) -(org-defkey org-mode-map (kbd "C-c C-M-l") #'org-insert-all-links) -(org-defkey org-mode-map (kbd "C-c C-o") #'org-open-at-point) -(org-defkey org-mode-map (kbd "C-c %") #'org-mark-ring-push) -(org-defkey org-mode-map (kbd "C-c &") #'org-mark-ring-goto) -(org-defkey org-mode-map (kbd "C-c C-z") #'org-add-note) ;alternative binding -(org-defkey org-mode-map (kbd "C-c .") #'org-time-stamp) ;minor-mode reserved -(org-defkey org-mode-map (kbd "C-c !") #'org-time-stamp-inactive) ;minor-mode r. -(org-defkey org-mode-map (kbd "C-c ,") #'org-priority) ;minor-mode reserved -(org-defkey org-mode-map (kbd "C-c C-y") #'org-evaluate-time-range) -(org-defkey org-mode-map (kbd "C-c >") #'org-goto-calendar) -(org-defkey org-mode-map (kbd "C-c <") #'org-date-from-calendar) -(org-defkey org-mode-map (kbd "C-,") #'org-cycle-agenda-files) -(org-defkey org-mode-map (kbd "C-'") #'org-cycle-agenda-files) -(org-defkey org-mode-map (kbd "C-c [") #'org-agenda-file-to-front) -(org-defkey org-mode-map (kbd "C-c ]") #'org-remove-file) -(org-defkey org-mode-map (kbd "C-c C-x <") #'org-agenda-set-restriction-lock) -(org-defkey org-mode-map (kbd "C-c C-x >") #'org-agenda-remove-restriction-lock) -(org-defkey org-mode-map (kbd "C-c -") #'org-ctrl-c-minus) -(org-defkey org-mode-map (kbd "C-c *") #'org-ctrl-c-star) -(org-defkey org-mode-map (kbd "C-c TAB") #'org-ctrl-c-tab) -(org-defkey org-mode-map (kbd "C-c ^") #'org-sort) -(org-defkey org-mode-map (kbd "C-c C-c") #'org-ctrl-c-ctrl-c) -(org-defkey org-mode-map (kbd "C-c C-k") #'org-kill-note-or-show-branches) -(org-defkey org-mode-map (kbd "C-c #") #'org-update-statistics-cookies) -(org-defkey org-mode-map (kbd "RET") #'org-return) -(org-defkey org-mode-map (kbd "C-j") #'org-return-indent) -(org-defkey org-mode-map (kbd "C-c ?") #'org-table-field-info) -(org-defkey org-mode-map (kbd "C-c SPC") #'org-table-blank-field) -(org-defkey org-mode-map (kbd "C-c +") #'org-table-sum) -(org-defkey org-mode-map (kbd "C-c =") #'org-table-eval-formula) -(org-defkey org-mode-map (kbd "C-c '") #'org-edit-special) -(org-defkey org-mode-map (kbd "C-c `") #'org-table-edit-field) -(org-defkey org-mode-map (kbd "C-c \" a") #'orgtbl-ascii-plot) -(org-defkey org-mode-map (kbd "C-c \" g") #'org-plot/gnuplot) -(org-defkey org-mode-map (kbd "C-c |") #'org-table-create-or-convert-from-region) -(org-defkey org-mode-map (kbd "C-#") #'org-table-rotate-recalc-marks) -(org-defkey org-mode-map (kbd "C-c ~") #'org-table-create-with-table.el) -(org-defkey org-mode-map (kbd "C-c C-a") #'org-attach) -(org-defkey org-mode-map (kbd "C-c }") #'org-table-toggle-coordinate-overlays) -(org-defkey org-mode-map (kbd "C-c {") #'org-table-toggle-formula-debugger) -(org-defkey org-mode-map (kbd "C-c C-e") #'org-export-dispatch) -(org-defkey org-mode-map (kbd "C-c :") #'org-toggle-fixed-width) -(org-defkey org-mode-map (kbd "C-c C-x C-f") #'org-emphasize) -(org-defkey org-mode-map (kbd "C-c C-x f") #'org-footnote-action) -(org-defkey org-mode-map (kbd "C-c @") #'org-mark-subtree) -(org-defkey org-mode-map (kbd "M-h") #'org-mark-element) -(org-defkey org-mode-map (kbd "ESC h") #'org-mark-element) -(org-defkey org-mode-map (kbd "C-c C-*") #'org-list-make-subtree) -(org-defkey org-mode-map (kbd "C-c C-x C-w") #'org-cut-special) -(org-defkey org-mode-map (kbd "C-c C-x M-w") #'org-copy-special) -(org-defkey org-mode-map (kbd "C-c C-x C-y") #'org-paste-special) -(org-defkey org-mode-map (kbd "C-c C-x C-t") #'org-toggle-time-stamp-overlays) -(org-defkey org-mode-map (kbd "C-c C-x C-i") #'org-clock-in) -(org-defkey org-mode-map (kbd "C-c C-x C-x") #'org-clock-in-last) -(org-defkey org-mode-map (kbd "C-c C-x C-z") #'org-resolve-clocks) -(org-defkey org-mode-map (kbd "C-c C-x C-o") #'org-clock-out) -(org-defkey org-mode-map (kbd "C-c C-x C-j") #'org-clock-goto) -(org-defkey org-mode-map (kbd "C-c C-x C-q") #'org-clock-cancel) -(org-defkey org-mode-map (kbd "C-c C-x C-d") #'org-clock-display) -(org-defkey org-mode-map (kbd "C-c C-x C-r") #'org-clock-report) -(org-defkey org-mode-map (kbd "C-c C-x C-u") #'org-dblock-update) -(org-defkey org-mode-map (kbd "C-c C-x C-l") #'org-toggle-latex-fragment) -(org-defkey org-mode-map (kbd "C-c C-x C-v") #'org-toggle-inline-images) -(org-defkey org-mode-map (kbd "C-c C-x C-M-v") #'org-redisplay-inline-images) -(org-defkey org-mode-map (kbd "C-c C-x \\") #'org-toggle-pretty-entities) -(org-defkey org-mode-map (kbd "C-c C-x C-b") #'org-toggle-checkbox) -(org-defkey org-mode-map (kbd "C-c C-x p") #'org-set-property) -(org-defkey org-mode-map (kbd "C-c C-x P") #'org-set-property-and-value) -(org-defkey org-mode-map (kbd "C-c C-x e") #'org-set-effort) -(org-defkey org-mode-map (kbd "C-c C-x E") #'org-inc-effort) -(org-defkey org-mode-map (kbd "C-c C-x o") #'org-toggle-ordered-property) -(org-defkey org-mode-map (kbd "C-c C-x i") #'org-columns-insert-dblock) -(org-defkey org-mode-map (kbd "C-c C-,") #'org-insert-structure-template) -(org-defkey org-mode-map (kbd "C-c C-x .") #'org-timer) -(org-defkey org-mode-map (kbd "C-c C-x -") #'org-timer-item) -(org-defkey org-mode-map (kbd "C-c C-x 0") #'org-timer-start) -(org-defkey org-mode-map (kbd "C-c C-x _") #'org-timer-stop) -(org-defkey org-mode-map (kbd "C-c C-x ;") #'org-timer-set-timer) -(org-defkey org-mode-map (kbd "C-c C-x ,") #'org-timer-pause-or-continue) -(org-defkey org-mode-map (kbd "C-c C-x C-c") #'org-columns) -(org-defkey org-mode-map (kbd "C-c C-x !") #'org-reload) -(org-defkey org-mode-map (kbd "C-c C-x g") #'org-feed-update-all) -(org-defkey org-mode-map (kbd "C-c C-x G") #'org-feed-goto-inbox) -(org-defkey org-mode-map (kbd "C-c C-x [") #'org-reftex-citation) -(org-defkey org-mode-map (kbd "C-c C-x I") #'org-info-find-node) - - -;;; Speed commands - -(defconst org-speed-commands-default - '( - ("Outline Navigation") - ("n" . (org-speed-move-safe 'org-next-visible-heading)) - ("p" . (org-speed-move-safe 'org-previous-visible-heading)) - ("f" . (org-speed-move-safe 'org-forward-heading-same-level)) - ("b" . (org-speed-move-safe 'org-backward-heading-same-level)) - ("F" . org-next-block) - ("B" . org-previous-block) - ("u" . (org-speed-move-safe 'outline-up-heading)) - ("j" . org-goto) - ("g" . (org-refile t)) - ("Outline Visibility") - ("c" . org-cycle) - ("C" . org-shifttab) - (" " . org-display-outline-path) - ("s" . org-toggle-narrow-to-subtree) - ("k" . org-cut-subtree) - ("=" . org-columns) - ("Outline Structure Editing") - ("U" . org-metaup) - ("D" . org-metadown) - ("r" . org-metaright) - ("l" . org-metaleft) - ("R" . org-shiftmetaright) - ("L" . org-shiftmetaleft) - ("i" . (progn (forward-char 1) (call-interactively - 'org-insert-heading-respect-content))) - ("^" . org-sort) - ("w" . org-refile) - ("a" . org-archive-subtree-default-with-confirmation) - ("@" . org-mark-subtree) - ("#" . org-toggle-comment) - ("Clock Commands") - ("I" . org-clock-in) - ("O" . org-clock-out) - ("Meta Data Editing") - ("t" . org-todo) - ("," . (org-priority)) - ("0" . (org-priority ?\ )) - ("1" . (org-priority ?A)) - ("2" . (org-priority ?B)) - ("3" . (org-priority ?C)) - (":" . org-set-tags-command) - ("e" . org-set-effort) - ("E" . org-inc-effort) - ("W" . (lambda(m) (interactive "sMinutes before warning: ") - (org-entry-put (point) "APPT_WARNTIME" m))) - ("Agenda Views etc") - ("v" . org-agenda) - ("/" . org-sparse-tree) - ("Misc") - ("o" . org-open-at-point) - ("?" . org-speed-command-help) - ("<" . (org-agenda-set-restriction-lock 'subtree)) - (">" . (org-agenda-remove-restriction-lock)) - ) - "The default speed commands.") - -(defun org-print-speed-command (e) - (if (> (length (car e)) 1) - (progn - (princ "\n") - (princ (car e)) - (princ "\n") - (princ (make-string (length (car e)) ?-)) - (princ "\n")) - (princ (car e)) - (princ " ") - (if (symbolp (cdr e)) - (princ (symbol-name (cdr e))) - (prin1 (cdr e))) - (princ "\n"))) - -(defun org-speed-command-help () - "Show the available speed commands." - (interactive) - (if (not org-use-speed-commands) - (user-error "Speed commands are not activated, customize `org-use-speed-commands'") - (with-output-to-temp-buffer "*Help*" - (princ "User-defined Speed commands\n===========================\n") - (mapc #'org-print-speed-command org-speed-commands-user) - (princ "\n") - (princ "Built-in Speed commands\n=======================\n") - (mapc #'org-print-speed-command org-speed-commands-default)) - (with-current-buffer "*Help*" - (setq truncate-lines t)))) - -(defun org-speed-move-safe (cmd) - "Execute CMD, but make sure that the cursor always ends up in a headline. -If not, return to the original position and throw an error." - (interactive) - (let ((pos (point))) - (call-interactively cmd) - (unless (and (bolp) (org-at-heading-p)) - (goto-char pos) - (error "Boundary reached while executing %s" cmd)))) - (defvar org-self-insert-command-undo-counter 0) - -(defvar org-table-auto-blank-field) ; defined in org-table.el (defvar org-speed-command nil) -(defun org-speed-command-activate (keys) - "Hook for activating single-letter speed commands. -`org-speed-commands-default' specifies a minimal command set. -Use `org-speed-commands-user' for further customization." - (when (or (and (bolp) (looking-at org-outline-regexp)) - (and (functionp org-use-speed-commands) - (funcall org-use-speed-commands))) - (cdr (assoc keys (append org-speed-commands-user - org-speed-commands-default))))) - -(defun org-babel-speed-command-activate (keys) - "Hook for activating single-letter code block commands." - (when (and (bolp) (looking-at org-babel-src-block-regexp)) - (cdr (assoc keys org-babel-key-bindings)))) - -(defcustom org-speed-command-hook - '(org-speed-command-activate org-babel-speed-command-activate) - "Hook for activating speed commands at strategic locations. -Hook functions are called in sequence until a valid handler is -found. - -Each hook takes a single argument, a user-pressed command key -which is also a `self-insert-command' from the global map. - -Within the hook, examine the cursor position and the command key -and return nil or a valid handler as appropriate. Handler could -be one of an interactive command, a function, or a form. - -Set `org-use-speed-commands' to non-nil value to enable this -hook. The default setting is `org-speed-command-activate'." - :group 'org-structure - :version "24.1" - :type 'hook) - (defun org-self-insert-command (N) "Like `self-insert-command', use overwrite-mode for whitespace in tables. If the cursor is in a table looking at whitespace, the whitespace is From bfd481be42bb46ff2a496c018093404b2485c3b0 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 5 Jul 2018 13:17:02 +0200 Subject: [PATCH 21/40] ob-core: Remove `org-babel-set-current-result-hash' * lisp/ob-core.el (org-babel-set-current-result-hash): Remove function, unused through the code base. --- etc/ORG-NEWS | 5 +++++ lisp/ob-core.el | 13 ------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index fee8dafca..dbe3c134e 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -50,6 +50,11 @@ the corresponding direction by swapping with the adjacent cell. *** ~org-table-cell-down~ *** ~org-table-cell-left~ *** ~org-table-cell-right~ +** Removed functions +*** ~org-babel-set-current-result-hash~ + +It was unused throughout the code base. + * Version 9.2 ** Incompatible changes *** Removal of OrgStruct mode mode and radio lists diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 32de18e77..5a902d28d 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -1291,19 +1291,6 @@ CONTEXT specifies the context of evaluation. It can be `:eval', (looking-at org-babel-result-regexp) (match-string-no-properties 1))))) -(defun org-babel-set-current-result-hash (hash info) - "Set the current in-buffer hash to HASH." - (org-with-wide-buffer - (goto-char (org-babel-where-is-src-block-result nil info)) - (looking-at org-babel-result-regexp) - (goto-char (match-beginning 1)) - (mapc #'delete-overlay (overlays-at (point))) - (forward-char org-babel-hash-show) - (mapc #'delete-overlay (overlays-at (point))) - (replace-match hash nil nil nil 1) - (beginning-of-line) - (org-babel-hide-hash))) - (defun org-babel-hide-hash () "Hide the hash in the current results line. Only the initial `org-babel-hash-show' characters of the hash From 3cb4ffe957d203d3c382d0ffbcfca1ee0d5d0318 Mon Sep 17 00:00:00 2001 From: Benjamin Motz Date: Wed, 4 Jul 2018 14:27:24 +0200 Subject: [PATCH 22/40] org-colview: Add property :exclude-tags to column view table * lisp/org-colview.el (org-columns--capture-view): Add parameter. (org-dblock-write:columnview): Add new property. * doc/org-manual.org (Capturing column view): Document feature. * testing/lisp/test-org-colview.el (test-org-colview/dblock): Add test. This addition allows to specify a list of tags to exclude from column view tables. TINYCHANGE --- doc/org-manual.org | 5 +++++ lisp/org-colview.el | 22 +++++++++++++++------- testing/lisp/test-org-colview.el | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 85e54b31e..e542bf7b2 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -5653,6 +5653,11 @@ This dynamic block has the following parameters: When non-~nil~, skip rows where the only non-empty specifier of the column view is =ITEM=. +- =:exclude-tags= :: + + List of tags to exclude from column view table: entries with + these tags will be excluded from the column view. + - =:indent= :: When non-~nil~, indent each =ITEM= field according to its level. diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 61a360ec0..5b3cf51e4 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1317,14 +1317,15 @@ and variances (respectively) of the individual estimates." ;;; Dynamic block for Column view -(defun org-columns--capture-view (maxlevel match skip-empty format local) +(defun org-columns--capture-view (maxlevel match skip-empty exclude-tags format local) "Get the column view of the current buffer. MAXLEVEL sets the level limit. SKIP-EMPTY tells whether to skip empty rows, an empty row being one where all the column view -specifiers but ITEM are empty. FORMAT is a format string for -columns, or nil. When LOCAL is non-nil, only capture headings in -current subtree. +specifiers but ITEM are empty. EXCLUDE-TAGS is a list of tags +that will be excluded from the resulting view. FORMAT is a +format string for columns, or nil. When LOCAL is non-nil, only +capture headings in current subtree. This function returns a list containing the title row and all other rows. Each row is a list of fields, as strings, or @@ -1347,9 +1348,13 @@ other rows. Each row is a list of fields, as strings, or 'org-columns-value 'org-columns-value-modified))) row))) - (unless (and skip-empty - (let ((r (delete-dups (remove "" row)))) - (or (null r) (and has-item (= (length r) 1))))) + (unless (or + (and skip-empty + (let ((r (delete-dups (remove "" row)))) + (or (null r) (and has-item (= (length r) 1))))) + (and exclude-tags + (cl-some (lambda (tag) (member tag exclude-tags)) + (org-get-tags)))) (push (cons (org-reduced-level (org-current-level)) (nreverse row)) table))))) (or (and maxlevel (format "LEVEL<=%d" maxlevel)) @@ -1394,6 +1399,8 @@ PARAMS is a property list of parameters: :match When set to a string, use this as a tags/property match filter. :skip-empty-rows When t, skip rows where all specifiers other than ITEM are empty. +:exclude-tags + List of tags to exclude from column view table. :format When non-nil, specify the column view format to use." (let ((table (let ((id (plist-get params :id)) @@ -1419,6 +1426,7 @@ PARAMS is a property list of parameters: (org-columns--capture-view (plist-get params :maxlevel) (plist-get params :match) (plist-get params :skip-empty-rows) + (plist-get params :exclude-tags) (plist-get params :format) view-pos)))))) (when table diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el index 6315d86c4..425ef4c3e 100644 --- a/testing/lisp/test-org-colview.el +++ b/testing/lisp/test-org-colview.el @@ -1470,6 +1470,26 @@ ** H1.1 :PROPERTIES: :A: 1 +:END:" + (let ((org-columns-default-format "%ITEM %A")) (org-update-dblock)) + (buffer-substring-no-properties (point) (outline-next-heading))))) + ;; Test `:exclude-tags' parameter. + (should + (equal + "#+BEGIN: columnview :exclude-tags (\"excludeme\") +| ITEM | A | +|------+---| +| H1 | | +#+END: +" + (org-test-with-temp-text + " +* H1 +#+BEGIN: columnview :exclude-tags (\"excludeme\") +#+END: +** H1.1 :excludeme: +:PROPERTIES: +:A: 1 :END:" (let ((org-columns-default-format "%ITEM %A")) (org-update-dblock)) (buffer-substring-no-properties (point) (outline-next-heading))))) From bb36c0c8ab5b0948f50f2f46ffc5f36b5327128d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 29 Sep 2018 22:42:17 +0200 Subject: [PATCH 23/40] Refactor `org-babel-load-file' * lisp/org.el (org-babel-load-file): Refactor code. --- lisp/org.el | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 11d0514c2..191a16868 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -242,35 +242,25 @@ Stars are put in group 1 and the trimmed body in group 2.") (fmakunbound (intern (concat "org-babel-expand-body:" lang))))))) -(declare-function org-babel-tangle-file "ob-tangle" (file &optional target-file lang)) + ;;;###autoload (defun org-babel-load-file (file &optional compile) "Load Emacs Lisp source code blocks in the Org FILE. This function exports the source code using `org-babel-tangle' -and then loads the resulting file using `load-file'. With prefix -arg (noninteractively: 2nd arg) COMPILE the tangled Emacs Lisp -file to byte-code before it is loaded." +and then loads the resulting file using `load-file'. With +optional prefix argument COMPILE, the tangled Emacs Lisp file is +byte-compiled before it is loaded." (interactive "fFile to load: \nP") - (let* ((age (lambda (file) - (float-time - (time-subtract (current-time) - (nth 5 (or (file-attributes (file-truename file)) - (file-attributes file))))))) - (base-name (file-name-sans-extension file)) - (exported-file (concat base-name ".el"))) - ;; tangle if the Org file is newer than the elisp file - (unless (and (file-exists-p exported-file) - (> (funcall age file) (funcall age exported-file))) - ;; Tangle-file traversal returns reversed list of tangled files - ;; and we want to evaluate the first target. - (setq exported-file - (car (last (org-babel-tangle-file file exported-file "emacs-lisp"))))) - (message "%s %s" - (if compile - (progn (byte-compile-file exported-file 'load) - "Compiled and loaded") - (progn (load-file exported-file) "Loaded")) - exported-file))) + (let* ((tangled-file (concat (file-name-sans-extension file) ".el"))) + ;; Tangle only if the Org file is newer than the Elisp file. + (unless (org-file-newer-than-p tangled-file (nth 5 (file-attributes file))) + (org-babel-tangle-file file tangled-file "emacs-lisp")) + (if compile + (progn + (byte-compile-file tangled-file 'load) + (message "Compiled and loaded %s" tangled-file)) + (load-file tangled-file) + (message "Loaded %s" tangled-file)))) (defcustom org-babel-load-languages '((emacs-lisp . t)) "Languages which can be evaluated in Org buffers. From 26ed66b23335eb389f1f2859e409f46f66279e15 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 6 Oct 2018 08:56:05 +0200 Subject: [PATCH 24/40] ob: :file and :file-ext no longer imply :results file * lisp/ob-core.el (org-babel-execute-src-block): ":results file" must be specified in order to return a file. (org-babel-merge-params): :file and :file-ext no longer imply :results file. * testing/lisp/test-ob.el (test-ob/indented-cached-org-bracket-link): (test-ob/result-file-link-type-header-argument): (test-ob/result-graphics-link-type-header-argument): Update tests. Deducing the results from some other arguments is not obvious. Moreover, it prevents users from setting, e.g., :file-ext, in a node property, as every block would then create a file. Reported-by: Alex Fenton --- etc/ORG-NEWS | 6 ++++++ lisp/ob-core.el | 16 ++-------------- testing/lisp/test-ob.el | 40 +++++++++++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index dbe3c134e..aa1b774c4 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -14,6 +14,12 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. ** Incompatible change +*** ~:file~ header argument no longer assume "file" ~:results~ + +The "file" ~:results~ value is now mandatory for a code block +returning a link to a file. The ~:file~ or ~:file-ext~ header +arguments no longer imply a "file" result is expected. + *** Plain numbers are hours in Column View mode See [[git:3367ac9457]] for details. diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 5a902d28d..7b7b3148e 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -694,7 +694,8 @@ block." (not (listp r))) (list (list r)) r))) - (let ((file (cdr (assq :file params)))) + (let ((file (and (member "file" result-params) + (cdr (assq :file params))))) ;; If non-empty result and :file then write to :file. (when file ;; If `:results' are special types like `link' or @@ -2624,19 +2625,6 @@ parameters when merging lists." results (split-string (if (stringp value) value (eval value t)))))) - (`(,(or :file :file-ext) . ,value) - ;; `:file' and `:file-ext' are regular keywords but they - ;; imply a "file" `:results' and a "results" `:exports'. - (when value - (setq results - (funcall merge results-exclusive-groups results '("file"))) - (unless (or (member "both" exports) - (member "none" exports) - (member "code" exports)) - (setq exports - (funcall merge - exports-exclusive-groups exports '("results")))) - (push pair params))) (`(:exports . ,value) (setq exports (funcall merge exports-exclusive-groups diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 095f66a76..28a735511 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -30,7 +30,7 @@ should still return the link." (org-test-with-temp-text " * Test - #+BEGIN_SRC emacs-lisp :file test.txt :cache yes + #+BEGIN_SRC emacs-lisp :results file :file test.txt :cache yes (message \"test\") #+END_SRC" ;; Execute twice as the first time creates the cache. @@ -1003,30 +1003,48 @@ trying to find the :END: marker." The file is just a link to `:file' value. Inhibit non-empty result write to `:file' value." (org-test-with-temp-text " +#+begin_src shell :results value file link :file \"/tmp/test.txt\" +echo \"hello\" > /tmp/test.txt +echo \"test\" +#+end_src" + (org-babel-execute-src-block) + (should (search-forward "[[file:/tmp/test.txt]]" nil t)) + (should (with-temp-buffer + (insert-file-contents "/tmp/test.txt") + (string= "hello\n" (buffer-string))))) + ;; Without "link" output type, the result is not a file. + (should-not + (org-test-with-temp-text " #+begin_src shell :results value link :file \"/tmp/test.txt\" echo \"hello\" > /tmp/test.txt echo \"test\" #+end_src" - (org-babel-execute-src-block) - (should (search-forward "[[file:/tmp/test.txt]]" nil nil)) - (should (with-temp-buffer - (insert-file-contents "/tmp/test.txt") - (string= "hello\n" (buffer-string)))))) + (org-babel-execute-src-block) + (search-forward "[[file:/tmp/test.txt]]" nil t)))) (ert-deftest test-ob/result-graphics-link-type-header-argument () "Ensure that the result is a link to a file. The file is just a link to `:file' value. Inhibit non-empty result write to `:file' value." (org-test-with-temp-text " +#+begin_src shell :results value file graphics :file \"/tmp/test.txt\" +echo \"hello\" > /tmp/test.txt +echo \"test\" +#+end_src" + (org-babel-execute-src-block) + (should (search-forward "[[file:/tmp/test.txt]]" nil nil)) + (should (with-temp-buffer + (insert-file-contents "/tmp/test.txt") + (string= "hello\n" (buffer-string))))) + ;; Without "link" output type, the result is not a file. + (should-not + (org-test-with-temp-text " #+begin_src shell :results value graphics :file \"/tmp/test.txt\" echo \"hello\" > /tmp/test.txt echo \"test\" #+end_src" - (org-babel-execute-src-block) - (should (search-forward "[[file:/tmp/test.txt]]" nil nil)) - (should (with-temp-buffer - (insert-file-contents "/tmp/test.txt") - (string= "hello\n" (buffer-string)))))) + (org-babel-execute-src-block) + (search-forward "[[file:/tmp/test.txt]]" nil t)))) (ert-deftest test-ob/inline-src_blk-preceded-punct-preceded-by-point () (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }") From 100541b53ca62be09d040274ee70a3354e15f14d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 6 Oct 2018 12:12:13 +0200 Subject: [PATCH 25/40] Bump version keyword to 9.3 --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 02b39f780..723a0de2f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7,7 +7,7 @@ ;; Maintainer: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: https://orgmode.org -;; Version: 9.2 +;; Version: 9.3 ;; ;; This file is part of GNU Emacs. ;; From 100edaccd160c4e9e5a7dc06291eb0802e20e78e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 13 Oct 2018 16:22:43 +0200 Subject: [PATCH 26/40] Implement `month' and `year' steps in clock tables * doc/org-manual.org (The clock table): Update manual. * lisp/org-clock.el (org-clocktable-steps): Rewrite function. Add `month' and `year' steps. * testing/lisp/test-org-clock.el (test-org-clock/clocktable/step): Add tests. --- doc/org-manual.org | 5 +- etc/ORG-NEWS | 1 + lisp/org-clock.el | 142 +++++++++++++++++++-------------- testing/lisp/test-org-clock.el | 106 +++++++++++++++++++++++- 4 files changed, 189 insertions(+), 65 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 84b7c7e83..636faaf99 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -6616,8 +6616,9 @@ be selected: - =:step= :: - Set to ~week~ or ~day~ to split the table into chunks. To use - this, ~:block~ or ~:tstart~, ~:tend~ are needed. + Set to =day=, =week=, =month= or =year= to split the table into + chunks. To use this, either =:block=, or =:tstart= and =:tend= + are required. - =:stepskip0= :: diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index aa1b774c4..fb02bdec8 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -47,6 +47,7 @@ system than the main Org document. For example: ,#+INCLUDE: "myfile.cmd" src cmd :coding cp850-dos #+end_example +*** New values in clock tables' step: =month= and =year= *** New cell movement functions in tables ~S-~, ~S-~, ~S-~, and ~S-~ now move cells in the corresponding direction by swapping with the adjacent cell. diff --git a/lisp/org-clock.el b/lisp/org-clock.el index ca05dfd71..3024df35b 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2682,69 +2682,87 @@ LEVEL is an integer. Indent by two spaces per level above 1." (concat "\\_" (make-string (* 2 (1- level)) ?\s)))) (defun org-clocktable-steps (params) - "Step through the range to make a number of clock tables." - (let* ((ts (plist-get params :tstart)) - (te (plist-get params :tend)) - (ws (plist-get params :wstart)) - (ms (plist-get params :mstart)) - (step0 (plist-get params :step)) - (step (cdr (assq step0 '((day . 86400) (week . 604800))))) - (stepskip0 (plist-get params :stepskip0)) - (block (plist-get params :block)) - cc tsb) - (when block - (setq cc (org-clock-special-range block nil t ws ms) - ts (car cc) - te (nth 1 cc))) - (cond - ((numberp ts) - ;; If ts is a number, it's an absolute day number from - ;; org-agenda. - (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute ts))) - (setq ts (float-time (encode-time 0 0 0 day month year))))) - (ts - (setq ts (float-time (apply #'encode-time (org-parse-time-string ts)))))) - (cond - ((numberp te) - ;; Likewise for te. - (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute te))) - (setq te (float-time (encode-time 0 0 0 day month year))))) - (te - (setq te (float-time (apply #'encode-time (org-parse-time-string te)))))) - (setq tsb - (if (eq step0 'week) - (let ((dow (nth 6 (decode-time (seconds-to-time ts))))) - (if (<= dow ws) ts - (- ts (* 86400 (- dow ws))))) - ts)) - (while (< tsb te) + "Create one ore more clock tables, according to PARAMS. +Step through the range specifications in plist PARAMS to make +a number of clock tables." + (let* ((ignore-empty-tables (plist-get params :stepskip0)) + (step (plist-get params :step)) + (step-header + (pcase step + (`day "Daily report: ") + (`week "Weekly report starting on: ") + (`month "Monthly report starting on: ") + (`year "Annual report starting on: ") + (_ (user-error "Unknown `:step' specification: %S" step)))) + (week-start (or (plist-get params :wstart) 1)) + (month-start (or (plist-get params :mstart) 1)) + (range + (pcase (plist-get params :block) + (`nil nil) + (range + (org-clock-special-range range nil t week-start month-start)))) + ;; For both START and END, any number is an absolute day + ;; number from Agenda. Otherwise, consider value to be an Org + ;; timestamp string. The `:block' property has precedence + ;; over `:tstart' and `:tend'. + (start + (apply #'encode-time + (pcase (if range (car range) (plist-get params :tstart)) + ((and (pred numberp) n) + (pcase-let + ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) + (list 0 0 org-extend-today-until d m y))) + (timestamp (org-parse-time-string timestamp))))) + (end + (apply #'encode-time + (pcase (if range (nth 1 range) (plist-get params :tend)) + ((and (pred numberp) n) + (pcase-let + ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) + (list 0 0 org-extend-today-until d m y))) + (timestamp (org-parse-time-string timestamp)))))) + (while (time-less-p start end) (unless (bolp) (insert "\n")) - (let ((start-time (seconds-to-time (max tsb ts)))) - (cl-incf tsb (let ((dow (nth 6 (decode-time (seconds-to-time tsb))))) - (if (or (eq step0 'day) - (= dow ws)) - step - (* 86400 (- ws dow))))) - (insert "\n" - (if (eq step0 'day) "Daily report: " - "Weekly report starting on: ") - (format-time-string (org-time-stamp-format nil t) start-time) - "\n") - (let ((table-begin (line-beginning-position 0)) - (step-time - (org-dblock-write:clocktable - (org-combine-plists - params - (list - :header "" :step nil :block nil - :tstart (format-time-string (org-time-stamp-format t t) - start-time) - :tend (format-time-string (org-time-stamp-format t t) - (seconds-to-time (min te tsb)))))))) - (re-search-forward "^[ \t]*#\\+END:") - (when (and stepskip0 (equal step-time 0)) - ;; Remove the empty table - (delete-region (line-beginning-position) table-begin)))) + ;; Insert header before each clock table. + (insert "\n" + step-header + (format-time-string (org-time-stamp-format nil t) start) + "\n") + ;; Compute NEXT, which is the end of the current clock table, + ;; according to step. + (let* ((next + (apply #'encode-time + (pcase-let + ((`(,_ ,_ ,_ ,d ,m ,y ,dow . ,_) (decode-time start))) + (pcase step + (`day (list 0 0 org-extend-today-until (1+ d) m y)) + (`week + (let ((offset (if (= dow week-start) 7 + (mod (- week-start dow) 7)))) + (list 0 0 org-extend-today-until (+ d offset) m y))) + (`month (list 0 0 0 month-start (1+ m) y)) + (`year (list 0 0 org-extend-today-until 1 1 (1+ y))))))) + (table-begin (line-beginning-position 0)) + (step-time + ;; Write clock table between START and NEXT. + (org-dblock-write:clocktable + (org-combine-plists + params (list :header "" + :step nil + :block nil + :tstart (format-time-string + (org-time-stamp-format t t) + start) + :tend (format-time-string + (org-time-stamp-format t t) + ;; Never include clocks past END. + (if (time-less-p end next) end next))))))) + (let ((case-fold-search t)) (re-search-forward "^[ \t]*#\\+END:")) + ;; Remove the table if it is empty and `:stepskip0' is + ;; non-nil. + (when (and ignore-empty-tables (equal step-time 0)) + (delete-region (line-beginning-position) table-begin)) + (setq start next)) (end-of-line 0)))) (defun org-clock-get-table-data (file params) diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index abb3637bd..3dcf25c5c 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -977,7 +977,111 @@ CLOCK: [2017-12-27 Wed 08:00]--[2017-12-27 Wed 16:00] => 8:00" (let ((system-time-locale "en_US")) (test-org-clock-clocktable-contents (concat ":step day :tstart \"<2017-12-25 Mon>\" " - ":tend \"<2017-12-27 Wed 23:59>\" :stepskip0 t"))))))) + ":tend \"<2017-12-27 Wed 23:59>\" :stepskip0 t")))))) + ;; Test :step week", without or with ":wstart" parameter. + (should + (equal " +Weekly report starting on: [2012-03-26 Mon] +| Headline | Time | +|--------------+--------| +| *Total time* | *8:00* | +|--------------+--------| +| Foo | 8:00 | + +Weekly report starting on: [2012-04-02 Mon] +| Headline | Time | +|--------------+--------| +| *Total time* | *8:00* | +|--------------+--------| +| Foo | 8:00 | +" + (org-test-with-temp-text + "* Foo +CLOCK: [2012-03-29 Thu 08:00]--[2012-03-29 Thu 16:00] => 8:00 +CLOCK: [2012-04-03 Thu 08:00]--[2012-04-03 Thu 16:00] => 8:00" + (let ((system-time-locale "en_US")) + (test-org-clock-clocktable-contents + ":step week :block 2012 :stepskip0 t"))))) + (should + (equal " +Weekly report starting on: [2012-03-29 Thu] +| Headline | Time | +|--------------+---------| +| *Total time* | *16:00* | +|--------------+---------| +| Foo | 16:00 | +" + (org-test-with-temp-text + "* Foo +CLOCK: [2012-03-29 Thu 08:00]--[2012-03-29 Thu 16:00] => 8:00 +CLOCK: [2012-04-03 Thu 08:00]--[2012-04-03 Thu 16:00] => 8:00" + (let ((system-time-locale "en_US")) + (test-org-clock-clocktable-contents + ":step week :wstart 4 :block 2012 :stepskip0 t"))))) + ;; Test ":step month" without and with ":mstart". + (should + (equal " +Monthly report starting on: [2014-03-01 Sat] +| Headline | Time | +|--------------+--------| +| *Total time* | *8:00* | +|--------------+--------| +| Foo | 8:00 | + +Monthly report starting on: [2014-04-01 Tue] +| Headline | Time | +|--------------+--------| +| *Total time* | *8:00* | +|--------------+--------| +| Foo | 8:00 | +" + (org-test-with-temp-text + "* Foo +CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00 +CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 16:00] => 8:00" + (let ((system-time-locale "en_US")) + (test-org-clock-clocktable-contents + ":step month :block 2014 :stepskip0 t"))))) + (should + (equal " +Monthly report starting on: [2014-03-04 Tue] +| Headline | Time | +|--------------+---------| +| *Total time* | *16:00* | +|--------------+---------| +| Foo | 16:00 | +" + (org-test-with-temp-text + "* Foo +CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00 +CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 16:00] => 8:00" + (let ((system-time-locale "en_US")) + (test-org-clock-clocktable-contents + ":step month :mstart 4 :block 2014 :stepskip0 t"))))) + ;; Test ":step year". + (should + (equal " +Annual report starting on: [2012-01-01 Sun] +| Headline | Time | +|--------------+--------| +| *Total time* | *8:00* | +|--------------+--------| +| Foo | 8:00 | + +Annual report starting on: [2014-01-01 Wed] +| Headline | Time | +|--------------+--------| +| *Total time* | *8:00* | +|--------------+--------| +| Foo | 8:00 | +" + (org-test-with-temp-text + "* Foo +CLOCK: [2012-03-29 Thu 08:00]--[2012-03-29 Thu 16:00] => 8:00 +CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00" + (let ((system-time-locale "en_US")) + (test-org-clock-clocktable-contents + ":step year :block untilnow :stepskip0 t")))))) (ert-deftest test-org-clock/clocktable/extend-today-until () "Test assignment of clock time to days in presence of \"org-extend-today-until\"." From 2b96fc9171733b725cdabb27d976733cfff50b6a Mon Sep 17 00:00:00 2001 From: Gong Qijian Date: Wed, 10 Oct 2018 20:28:10 +0800 Subject: [PATCH 27/40] ob-core: Fix `org-babel--string-to-number' * lisp/ob-core.el (org-babel--string-to-number): Fix the regular expression. * testing/lisp/test-ob.el (test-ob/string-to-number): Test cases. If people write the data in the form "0001"", it means that he wants to treat it as a string. TINYCHANGE > #+name: TBL > | id | name | age | > |------|--------|-----| > | 0001 | Apollo | 16 | > | 0002 | Bmw | 16 | > > #+BEGIN_SRC emacs-lisp :results value pp :var tbl=TBL > (mapc 'print tbl) > #+END_SRC > > #+RESULTS: > : (("0001" "Apollo" 16) > : ("0002" "Bmw" 16)) TINYCHANGE --- etc/ORG-NEWS | 2 ++ lisp/ob-core.el | 2 +- testing/lisp/test-ob.el | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index fb02bdec8..75f404fb3 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -62,6 +62,8 @@ the corresponding direction by swapping with the adjacent cell. It was unused throughout the code base. +** Miscellaneous +*** Org Table reads numbers starting with 0 as strings * Version 9.2 ** Incompatible changes *** Removal of OrgStruct mode mode and radio lists diff --git a/lisp/ob-core.el b/lisp/ob-core.el index da9fa31e0..be73ca5b6 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2915,7 +2915,7 @@ situations in which is it not appropriate." (defun org-babel--string-to-number (string) "If STRING represents a number return its value. Otherwise return nil." - (and (string-match-p "\\`-?[0-9]*\\.?[0-9]*\\'" string) + (and (string-match-p "\\`-?\\([0-9]\\|\\([1-9]\\|[0-9]*\\.\\)[0-9]*\\)\\'" string) (string-to-number string))) (defun org-babel-import-elisp-from-file (file-name &optional separator) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 28a735511..037d9e289 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -2034,6 +2034,16 @@ abc (let ((org-coderef-label-format "#(ref:%s)")) (org-babel-execute-src-block)))))) +(ert-deftest test-ob/string-to-number () + (should (= 0 (org-babel--string-to-number "0"))) + (should (= 1 (org-babel--string-to-number "1"))) + (should (eq nil (org-babel--string-to-number "000"))) + (should (eq nil (org-babel--string-to-number "001"))) + (should (eq nil (org-babel--string-to-number "010"))) + (should (= 100 (org-babel--string-to-number "100"))) + (should (= 0.1 (org-babel--string-to-number "0.1"))) + (should (= 1.0 (org-babel--string-to-number "1.0")))) + (provide 'test-ob) ;;; test-ob ends here From eb806aa50331ac221a0544c3ebc375ac5af63413 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Fri, 19 Oct 2018 09:19:38 -0400 Subject: [PATCH 28/40] ox-odt: Add support for text:start-value * lisp/ox-odt.el (org-odt-item): Support starting lists at a set number via "text:start-value". Without this, ODF files just restart numbering when they should continue with the specified number. --- etc/ORG-NEWS | 1 + lisp/ox-odt.el | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 75f404fb3..2a6e9fcef 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -48,6 +48,7 @@ system than the main Org document. For example: #+end_example *** New values in clock tables' step: =month= and =year= +*** ODT export handles numbers cookies in lists *** New cell movement functions in tables ~S-~, ~S-~, ~S-~, and ~S-~ now move cells in the corresponding direction by swapping with the adjacent cell. diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 70ef9de2e..66be39f2e 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -1966,10 +1966,12 @@ contextual information." CONTENTS holds the contents of the item. INFO is a plist holding contextual information." (let* ((plain-list (org-export-get-parent item)) + (count (org-element-property :counter item)) (type (org-element-property :type plain-list))) (unless (memq type '(ordered unordered descriptive-1 descriptive-2)) (error "Unknown list type: %S" type)) - (format "\n\n%s\n%s" + (format "\n\n%s\n%s" + (if count (format " text:start-value=\"%s\"" count) "") contents (if (org-element-map item 'table #'identity info 'first-match) "" From bb29ee41b33a6ef2c68e701a6ac9cca49b89cb2a Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 22 Oct 2018 14:06:04 +0200 Subject: [PATCH 29/40] org-manual: Reference "davs" Tramp's protocol * doc/org-manual.org (Setting up the staging area): Reference "davs" Tramp's protocol as an example to access a WebDAV server. --- doc/org-manual.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index f9aba5bb5..b4be20f0c 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -19321,10 +19321,10 @@ locally just set the variable to point to that directory: Alternatively, by using TRAMP (see [[info:tramp][TRAMP User Manual]]), ~org-mobile-directory~ may point to a remote directory accessible -through, for example, SSH and SCP: +through, for example, SSH, SCP, or DAVS: #+begin_src emacs-lisp -(setq org-mobile-directory "/scpc:user@remote.host:org/webdav/") +(setq org-mobile-directory "/davs:user@remote.host:/org/webdav/") #+end_src #+vindex: org-mobile-encryption From 4456dc88097815bc91fa062e459e093f4536cb41 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Thu, 19 Apr 2018 18:16:27 +0800 Subject: [PATCH 30/40] ob-clojure: Support `org-babel-initiate-session' * ob-clojure.el (org-babel-clojure-initiate-session): Initialize session for source block. (org-babel-prep-session:clojure): Prepare Clojure session. (org-babel-clojure-var-to-clojure): Convert header argument :var into clojure variables definitions. (org-babel-variable-assignments:clojure): Support assigning variables when initializing a session. --- contrib/lisp/ob-clojure-literate.el | 56 --------------------- lisp/ob-clojure.el | 55 +++++++++++++++++++++ testing/lisp/test-ob-clojure.el | 77 +++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 56 deletions(-) create mode 100644 testing/lisp/test-ob-clojure.el diff --git a/contrib/lisp/ob-clojure-literate.el b/contrib/lisp/ob-clojure-literate.el index 4c4d38a0f..b1cc386ee 100644 --- a/contrib/lisp/ob-clojure-literate.el +++ b/contrib/lisp/ob-clojure-literate.el @@ -184,62 +184,6 @@ If it is a directory, `ob-clojure-literate' will try to create Clojure project a (lambda (cons) (if (eq (car cons) :session) t cons)) org-babel-default-header-args:clojure))))) -;;; Support `org-babel-initiate-session' / [C-c C-v z] to initialize Clojure session. - -(defun org-babel-clojure-initiate-session (&optional session _params) - "Initiate a session named SESSION according to PARAMS." - (when (and session (not (string= session "none"))) - (save-window-excursion - (unless (org-babel-comint-buffer-livep session) - ;; CIDER jack-in to the Clojure project directory. - (cond - ((eq org-babel-clojure-backend 'cider) - (require 'cider) - (let ((session-buffer (save-window-excursion - (cider-jack-in t) - (current-buffer)))) - (if (org-babel-comint-buffer-livep session-buffer) - (progn (sit-for .25) session-buffer)))) - ((eq org-babel-clojure-backend 'slime) - (error "Session evaluation with SLIME is not supported")) - (t - (error "Session initiate failed"))) - ) - (get-buffer session) - ))) - -(defun org-babel-prep-session:clojure (session params) - "Prepare SESSION according to the header arguments specified in PARAMS." - (let* ((session (org-babel-clojure-initiate-session session)) - (var-lines (org-babel-variable-assignments:clojure params))) - (when session - (org-babel-comint-in-buffer session - (mapc (lambda (var) - (insert var) (comint-send-input nil t) - (org-babel-comint-wait-for-output session) - (sit-for .1) (goto-char (point-max))) var-lines))) - session)) - -(defun org-babel-clojure-var-to-clojure (var) - "Convert src block's `VAR' to Clojure variable." - (if (listp var) - (replace-regexp-in-string "(" "'(" var) - (cond - ((stringp var) - ;; wrap org-babel passed in header argument value with quote in Clojure. - (format "\"%s\"" var)) - (t - (format "%s" var)))) - ) - -(defun org-babel-variable-assignments:clojure (params) - "Return a list of Clojure statements assigning the block's variables in `PARAMS'." - (mapcar - (lambda (pair) - (format "(def %s %s)" - (car pair) - (org-babel-clojure-var-to-clojure (cdr pair)))) - (org-babel--get-vars params))) ;;; Support header arguments :results graphics :file "image.png" by inject Clojure code. (defun ob-clojure-literate-inject-code (args) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index d5b918b01..048ba3735 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -43,6 +43,7 @@ (require 'ob) (require 'org-macs) +(declare-function cider-jack-in "ext:cider" (&optional prompt-project cljs-too)) (declare-function cider-current-connection "ext:cider-client" (&optional type)) (declare-function cider-current-ns "ext:cider-client" ()) (declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2)) @@ -211,6 +212,60 @@ using the :show-process parameter." (condition-case nil (org-babel-script-escape result) (error result))))) +(defun org-babel-clojure-initiate-session (&optional session _params) + "Initiate a session named SESSION according to PARAMS." + (when (and session (not (string= session "none"))) + (save-window-excursion + (cond + ((org-babel-comint-buffer-livep session) nil) + ;; CIDER jack-in to the Clojure project directory. + ((eq org-babel-clojure-backend 'cider) + (require 'cider) + (let ((session-buffer (save-window-excursion + (cider-jack-in t) + (current-buffer)))) + (if (org-babel-comint-buffer-livep session-buffer) + (progn (sit-for .25) session-buffer)))) + ((eq org-babel-clojure-backend 'slime) + (error "Session evaluation with SLIME is not supported")) + (t + (error "Session initiate failed"))) + (get-buffer session)))) + +(defun org-babel-prep-session:clojure (session params) + "Prepare SESSION according to the header arguments specified in PARAMS." + (let ((session (org-babel-clojure-initiate-session session)) + (var-lines (org-babel-variable-assignments:clojure params))) + (when session + (org-babel-comint-in-buffer session + (dolist (var var-lines) + (insert var) + (comint-send-input nil t) + (org-babel-comint-wait-for-output session) + (sit-for .1) + (goto-char (point-max))))) + session)) + +(defun org-babel-clojure-var-to-clojure (var) + "Convert src block's VAR to Clojure variable." + (cond + ((listp var) + (replace-regexp-in-string "(" "'(" var)) + ((stringp var) + ;; Wrap Babel passed-in header argument value with quotes in Clojure. + (format "\"%s\"" var)) + (t + (format "%S" var)))) + +(defun org-babel-variable-assignments:clojure (params) + "Return a list of Clojure statements assigning the block's variables in PARAMS." + (mapcar + (lambda (pair) + (format "(def %s %s)" + (car pair) + (org-babel-clojure-var-to-clojure (cdr pair)))) + (org-babel--get-vars params))) + (provide 'ob-clojure) ;;; ob-clojure.el ends here diff --git a/testing/lisp/test-ob-clojure.el b/testing/lisp/test-ob-clojure.el new file mode 100644 index 000000000..f917ca4cc --- /dev/null +++ b/testing/lisp/test-ob-clojure.el @@ -0,0 +1,77 @@ +;;; test-ob-clojure.el + +;; Copyright (c) 2018-2022 Free Software Foundation, Inc. +;; Authors: stardiviner + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Comments: + +;; Org tests for ob-clojure.el live here + +;;; Code: +(org-test-for-executable "cider") +(unless (featurep 'cider) + (signal 'missing-test-dependency "CIDER")) +(unless (featurep 'ob-clojure) + (signal 'missing-test-dependency "Support for Clojure code blocks")) + +(ert-deftest ob-clojure/simple-session () + (org-test-with-temp-text + "#+begin_src clojure :session +(print \"hello, world\") +#+end_src +" + (should (string= "hello, world" (org-babel-execute-src-block))))) + +(ert-deftest ob-clojure/initiate-session () + (org-test-with-temp-text + "#+begin_src clojure :session :var a=1 :results output +(print \"hello, world\") +#+end_src + +#+begin_src clojure :session :results output +(print a) +#+end_src" + (goto-char (point-min)) + (org-babel-switch-to-session) + (sleep-for 2) + (org-babel-execute-maybe) + (org-babel-next-src-block) + (goto-char (org-babel-result-end)) + (forward-line 2) + (should (string= + ": 1" + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))) + +(ert-deftest ob-clojure/initiate-session-with-var () + (org-test-with-temp-text + "#+begin_src clojure :session :var a=1 :results output +(print a) +#+end_src" + (org-babel-next-src-block) + (org-babel-initiate-session) + (sleep-for 2) + (org-babel-execute-maybe) + (goto-char (org-babel-result-end)) + (forward-line 2) + (should (string= + ": 1" + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))) + +(provide 'test-ob-clojure) + + ;;; test-ob-clojure.el ends here From 2c5df17ed1d7f61d4b3cbb92d17de2c25baa354e Mon Sep 17 00:00:00 2001 From: stardiviner Date: Tue, 23 Oct 2018 19:23:45 +0800 Subject: [PATCH 31/40] ob-clojure: Support new CIDER using sesman to manage sessions * ob-clojure.el (org-babel-clojure-initiate-session): Improve ob-clojure initialize session way to support CIDER new API. * etc/ORG-NEWS: Add declare for new :session support feature. --- etc/ORG-NEWS | 11 +++++++++++ lisp/ob-clojure.el | 22 +++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 2a6e9fcef..2bef7a1fe 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -225,6 +225,17 @@ This is consistent with the naming of =org-dblock-write:columnview= options, where =:match= is also used as a headlines filter. ** New features +*** Add ~:session~ support of ob-clojure for CIDER +You can initialize source block session with Babel default keybinding +=[C-c C-v C-z]= to use =sesman= session manager to link current +project, directory or buffer with specific Clojure session, or +=cider-jack-in= a new CIDER REPL if no CIDER REPLs available. In older +CIDER version which has not =sesman= integrated, only has +=cider-jack-in= without Clojure project is supported. +#+begin_src clojure :session +(dissoc Clojure 'JVM) +(conj clojurists "stardiviner") +#+end_src *** Add ~:results link~ support for Babel With this output format, create a link to the file specified in diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 048ba3735..e02b2d825 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -46,6 +46,7 @@ (declare-function cider-jack-in "ext:cider" (&optional prompt-project cljs-too)) (declare-function cider-current-connection "ext:cider-client" (&optional type)) (declare-function cider-current-ns "ext:cider-client" ()) +(declare-function cider-repls "ext:cider-connection" (&optional type ensure)) (declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2)) (declare-function nrepl-dict-get "ext:nrepl-client" (dict key)) (declare-function nrepl-dict-put "ext:nrepl-client" (dict key value)) @@ -55,6 +56,8 @@ (defvar nrepl-sync-request-timeout) (defvar cider-buffer-ns) +(defvar sesman-system) +(defvar cider-version) (defvar org-babel-tangle-lang-exts) (add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj")) @@ -221,11 +224,20 @@ using the :show-process parameter." ;; CIDER jack-in to the Clojure project directory. ((eq org-babel-clojure-backend 'cider) (require 'cider) - (let ((session-buffer (save-window-excursion - (cider-jack-in t) - (current-buffer)))) - (if (org-babel-comint-buffer-livep session-buffer) - (progn (sit-for .25) session-buffer)))) + (let ((session-buffer + (save-window-excursion + (if (version< cider-version "0.18.0") + ;; Older CIDER (without sesman) still need to use + ;; old way. + (cider-jack-in nil) ;jack-in without project + ;; New CIDER (with sesman to manage sessions). + (unless (cider-repls) + (let ((sesman-system 'CIDER)) + (call-interactively 'sesman-link-with-directory)))) + (current-buffer)))) + (when (org-babel-comint-buffer-livep session-buffer) + (sit-for .25) + session-buffer))) ((eq org-babel-clojure-backend 'slime) (error "Session evaluation with SLIME is not supported")) (t From 363df82b19a28fde8d13f322dc2626c5cbadf715 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 1 Nov 2018 23:00:45 +0100 Subject: [PATCH 32/40] Change default value for `org-email-link-description-format' * lisp/org.el (org-email-link-description-format): Change default value. No longer truncate subject by default. Add `:safe' keyword. * doc/org-manual.org (Handling Links): Document change. Reported-by: "Garreau, Alexandre" --- doc/org-manual.org | 2 +- etc/ORG-NEWS | 11 +++++++++++ lisp/org.el | 6 ++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 38f551a6e..157a57d4b 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -3289,7 +3289,7 @@ current buffer: points to the current article, or, in some Gnus buffers, to the group. The description is constructed according to the variable ~org-email-link-description-format~. By default, it refers to - the addressee and the subject, possibly truncated. + the addressee and the subject. - /Web browsers: W3, W3M and EWW/ :: diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 2bef7a1fe..d3be383ac 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -14,6 +14,17 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. ** Incompatible change +*** Change default value for ~org-email-link-description-format~ + +When linking from a mail buffer, Org used to truncate the subject of +the message to 30 characters in order to build the description of the +link. This behavior was considered as too surprising. As +a consequence, Org no longer truncates subjects. + +You can get the old behaviour back with the following: + +: (setq org-email-link-description-format "Email %c: %.30s") + *** ~:file~ header argument no longer assume "file" ~:results~ The "file" ~:results~ value is now mandatory for a code block diff --git a/lisp/org.el b/lisp/org.el index 5591c1d4a..67b230502 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1867,7 +1867,7 @@ use." :version "24.3" :group 'org-link-store) -(defcustom org-email-link-description-format "Email %c: %.30s" +(defcustom org-email-link-description-format "Email %c: %s" "Format of the description part of a link to an email or usenet message. The following %-escapes will be replaced by corresponding information: @@ -1886,7 +1886,9 @@ This is for example useful to limit the length of the subject. Examples: \"%f on: %.30s\", \"Email from %f\", \"Email %c\"" :group 'org-link-store - :type 'string) + :package-version '(Org . 9.3) + :type 'string + :safe #'stringp) (defcustom org-from-is-user-regexp (let (r1 r2) From ae03104402ed3e899cc5fcd896ea9def4ba313c3 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 2 Nov 2018 02:04:38 +0100 Subject: [PATCH 33/40] org-attach: Attach buffers to tasks * lisp/org-attach.el (org-attach-buffer): New function. (org-attach): Call new function. * doc/org-manual.org (Attachments): Document new function. --- doc/org-manual.org | 130 ++++++++++++++++++++++++--------------------- etc/ORG-NEWS | 4 ++ lisp/org-attach.el | 19 ++++++- 3 files changed, 90 insertions(+), 63 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 157a57d4b..cc9d3eb5b 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -7586,91 +7586,97 @@ The following commands deal with attachments: After these keys, a list of commands is displayed and you must press an additional key to select a command: - - {{{kbd(a)}}} (~org-attach-attach~) :: + - {{{kbd(a)}}} (~org-attach-attach~) :: - #+kindex: C-c C-a a - #+findex: org-attach-attach - #+vindex: org-attach-method - Select a file and move it into the task's attachment - directory. The file is copied, moved, or linked, depending - on ~org-attach-method~. Note that hard links are not - supported on all systems. + #+kindex: C-c C-a a + #+findex: org-attach-attach + #+vindex: org-attach-method + Select a file and move it into the task's attachment directory. + The file is copied, moved, or linked, depending on + ~org-attach-method~. Note that hard links are not supported on + all systems. - - {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} :: + - {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} :: - #+kindex: C-c C-a c - #+kindex: C-c C-a m - #+kindex: C-c C-a l - Attach a file using the copy/move/link method. Note that - hard links are not supported on all systems. + #+kindex: C-c C-a c + #+kindex: C-c C-a m + #+kindex: C-c C-a l + Attach a file using the copy/move/link method. Note that hard + links are not supported on all systems. - - {{{kbd(n)}}} (~org-attach-new~) :: + - {{{kbd(b)}}} (~org-attach-buffer~) :: - #+kindex: C-c C-a n - #+findex: org-attach-new - Create a new attachment as an Emacs buffer. + #+kindex: C-c C-a b + #+findex: org-attach-buffer + Select a buffer and save it as a file in the task's attachment + directory. - - {{{kbd(z)}}} (~org-attach-sync~) :: + - {{{kbd(n)}}} (~org-attach-new~) :: - #+kindex: C-c C-a z - #+findex: org-attach-sync - Synchronize the current task with its attachment directory, in case - you added attachments yourself. + #+kindex: C-c C-a n + #+findex: org-attach-new + Create a new attachment as an Emacs buffer. - - {{{kbd(o)}}} (~org-attach-open~) :: + - {{{kbd(z)}}} (~org-attach-sync~) :: - #+kindex: C-c C-a o - #+findex: org-attach-open - #+vindex: org-file-apps - Open current task's attachment. If there is more than one, - prompt for a file name first. Opening follows the rules set - by ~org-file-apps~. For more details, see the information - on following hyperlinks (see [[*Handling Links]]). + #+kindex: C-c C-a z + #+findex: org-attach-sync + Synchronize the current task with its attachment directory, in + case you added attachments yourself. - - {{{kbd(O)}}} (~org-attach-open-in-emacs~) :: + - {{{kbd(o)}}} (~org-attach-open~) :: - #+kindex: C-c C-a O - #+findex: org-attach-open-in-emacs - Also open the attachment, but force opening the file in - Emacs. + #+kindex: C-c C-a o + #+findex: org-attach-open + #+vindex: org-file-apps + Open current task's attachment. If there is more than one, + prompt for a file name first. Opening follows the rules set by + ~org-file-apps~. For more details, see the information on + following hyperlinks (see [[*Handling Links]]). - - {{{kbd(f)}}} (~org-attach-reveal~) :: + - {{{kbd(O)}}} (~org-attach-open-in-emacs~) :: - #+kindex: C-c C-a f - #+findex: org-attach-reveal - Open the current task's attachment directory. + #+kindex: C-c C-a O + #+findex: org-attach-open-in-emacs + Also open the attachment, but force opening the file in Emacs. - - {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) :: + - {{{kbd(f)}}} (~org-attach-reveal~) :: - #+kindex: C-c C-a F - #+findex: org-attach-reveal-in-emacs - Also open the directory, but force using Dired in Emacs. + #+kindex: C-c C-a f + #+findex: org-attach-reveal + Open the current task's attachment directory. - - {{{kbd(d)}}} (~org-attach-delete-one~) :: + - {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) :: - #+kindex: C-c C-a d - Select and delete a single attachment. + #+kindex: C-c C-a F + #+findex: org-attach-reveal-in-emacs + Also open the directory, but force using Dired in Emacs. - - {{{kbd(D)}}} (~org-attach-delete-all~) :: + - {{{kbd(d)}}} (~org-attach-delete-one~) :: - #+kindex: C-c C-a D - Delete all of a task's attachments. A safer way is to open - the directory in Dired and delete from there. + #+kindex: C-c C-a d + Select and delete a single attachment. - - {{{kbd(s)}}} (~org-attach-set-directory~) :: + - {{{kbd(D)}}} (~org-attach-delete-all~) :: - #+kindex: C-c C-a s - #+cindex: @samp{ATTACH_DIR}, property - Set a specific directory as the entry's attachment - directory. This works by putting the directory path into - the =ATTACH_DIR= property. + #+kindex: C-c C-a D + Delete all of a task's attachments. A safer way is to open the + directory in Dired and delete from there. - - {{{kbd(i)}}} (~org-attach-set-inherit~) :: + - {{{kbd(s)}}} (~org-attach-set-directory~) :: - #+kindex: C-c C-a i - #+cindex: @samp{ATTACH_DIR_INHERIT}, property - Set the =ATTACH_DIR_INHERIT= property, so that children use - the same directory for attachments as the parent does. + #+kindex: C-c C-a s + #+cindex: @samp{ATTACH_DIR}, property + Set a specific directory as the entry's attachment directory. + This works by putting the directory path into the =ATTACH_DIR= + property. + + - {{{kbd(i)}}} (~org-attach-set-inherit~) :: + + #+kindex: C-c C-a i + #+cindex: @samp{ATTACH_DIR_INHERIT}, property + Set the =ATTACH_DIR_INHERIT= property, so that children use the + same directory for attachments as the parent does. #+cindex: attach from Dired #+findex: org-attach-dired-to-subtree diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index d3be383ac..e84b10f2e 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -38,6 +38,10 @@ See [[git:3367ac9457]] for details. ** New features *** Babel **** Add LaTeX output support in PlantUML +*** Attach buffer contents to headline +With == key from attachment dispatcher (==), it is now +possible to write the contents of a buffer to a file in the headline +attachement directory. *** iCalendar export respects a =CLASS= property Set the =CLASS= property on an entry to specify a visibility class for diff --git a/lisp/org-attach.el b/lisp/org-attach.el index e827d3721..219928162 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -177,6 +177,7 @@ Shows a list of commands and prompts for another key to execute a command." a Select a file and attach it to the task, using `org-attach-method'. c/m/l/y Attach a file using copy/move/link/symbolic-link method. u Attach a file from URL (downloading it). +b Select a buffer and attach its contents to the task. n Create a new attachment, as an Emacs buffer. z Synchronize the current task with its attachment directory, in case you added attachments yourself. @@ -193,7 +194,7 @@ D Delete all of a task's attachments. A safer way is s Set a specific attachment directory for this entry or reset to default. i Make children of the current entry inherit its attachment directory."))) (org-fit-window-to-buffer (get-buffer-window "*Org Attach*")) - (message "Select command: [acmlyunzoOfFdD]") + (message "Select command: [acmlyubnzoOfFdD]") (setq c (read-char-exclusive)) (and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*")))) (cond @@ -208,6 +209,7 @@ i Make children of the current entry inherit its attachment directory."))) (let ((org-attach-method 'lns)) (call-interactively 'org-attach-attach))) ((memq c '(?u ?\C-u)) (let ((org-attach-method 'url)) (call-interactively 'org-attach-url))) + ((eq c ?b) (call-interactively 'org-attach-buffer)) ((memq c '(?n ?\C-n)) (call-interactively 'org-attach-new)) ((memq c '(?z ?\C-z)) (call-interactively 'org-attach-sync)) ((memq c '(?o ?\C-o)) (call-interactively 'org-attach-open)) @@ -390,6 +392,21 @@ Only do this when `org-attach-store-link-p' is non-nil." (interactive "MURL of the file to attach: \n") (org-attach-attach url)) +(defun org-attach-buffer (buffer-name) + "Attach BUFFER-NAME's contents to current task. +BUFFER-NAME is a string. Signals a `file-already-exists' error +if it would overwrite an existing filename." + (interactive "bBuffer whose contents should be attached: ") + (let ((output (expand-file-name buffer-name (org-attach-dir t)))) + (when (file-exists-p output) + (signal 'file-already-exists (list "File exists" output))) + (when (and org-attach-file-list-property (not org-attach-inherited)) + (org-entry-add-to-multivalued-property + (point) org-attach-file-list-property buffer-name)) + (org-attach-tag) + (with-temp-file output + (insert-buffer-substring buffer-name)))) + (defun org-attach-attach (file &optional visit-dir method) "Move/copy/link FILE into the attachment directory of the current task. If VISIT-DIR is non-nil, visit the directory with dired. From 655c08dcc86cdcd46097bd22e293314f42456426 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 27 Nov 2018 00:18:28 +0100 Subject: [PATCH 34/40] org-clock: Fix failing tests * lisp/org-clock.el (org-clocktable-steps): Fix type of START and END bindings. --- lisp/org-clock.el | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 0fc15a0fa..0f146ee43 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2706,21 +2706,17 @@ a number of clock tables." ;; timestamp string. The `:block' property has precedence ;; over `:tstart' and `:tend'. (start - (apply #'encode-time - (pcase (if range (car range) (plist-get params :tstart)) - ((and (pred numberp) n) - (pcase-let - ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) - (list 0 0 org-extend-today-until d m y))) - (timestamp (org-matcher-time timestamp))))) + (pcase (if range (car range) (plist-get params :tstart)) + ((and (pred numberp) n) + (pcase-let ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) + (apply #'encode-time (list 0 0 org-extend-today-until d m y)))) + (timestamp (seconds-to-time (org-matcher-time timestamp))))) (end - (apply #'encode-time - (pcase (if range (nth 1 range) (plist-get params :tend)) - ((and (pred numberp) n) - (pcase-let - ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) - (list 0 0 org-extend-today-until d m y))) - (timestamp (org-matcher-time timestamp)))))) + (pcase (if range (nth 1 range) (plist-get params :tend)) + ((and (pred numberp) n) + (pcase-let ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) + (apply #'encode-time (list 0 0 org-extend-today-until d m y)))) + (timestamp (seconds-to-time (org-matcher-time timestamp)))))) (while (time-less-p start end) (unless (bolp) (insert "\n")) ;; Insert header before each clock table. From 819e98afd018cad3c13fd58bfcbd979ab36dfbc7 Mon Sep 17 00:00:00 2001 From: Matt Price Date: Tue, 27 Nov 2018 21:32:07 +0100 Subject: [PATCH 35/40] org-src: Do not restore window config when exiting an edit buffer org-src.el (org-src--saved-temp-window-config): Remove variable. * lisp/org-src.el (org-src--edit-element): Apply removal. --- etc/ORG-NEWS | 8 ++++++-- lisp/org-src.el | 9 +-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index e84b10f2e..6b09cdc5b 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -12,8 +12,12 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.3 -** Incompatible change - +** Incompatible changes +*** Change in behavior on exit from an Org edit buffer +Org will no longer attempt to restore the window configuration in the +frame to which the user returns after editing a source block with +~org-edit-src-code~. Instead, the window configuration will remain as +it is. *** Change default value for ~org-email-link-description-format~ When linking from a mail buffer, Org used to truncate the subject of diff --git a/lisp/org-src.el b/lisp/org-src.el index 08deda4d2..d383339e0 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -270,9 +270,6 @@ issued in the language major mode buffer." (defvar-local org-src--remote nil) (put 'org-src--remote 'permanent-local t) -(defvar-local org-src--saved-temp-window-config nil) -(put 'org-src--saved-temp-window-config 'permanent-local t) - (defvar-local org-src--source-type nil "Type of element being edited, as a symbol.") (put 'org-src--source-type 'permanent-local t) @@ -475,7 +472,6 @@ When REMOTE is non-nil, do not try to preserve point or mark when moving from the edit area to the source. Leave point in edit buffer." - (setq org-src--saved-temp-window-config (current-window-configuration)) (let* ((area (org-src--contents-area datum)) (beg (copy-marker (nth 0 area))) (end (copy-marker (nth 1 area) t)) @@ -1172,10 +1168,7 @@ Throw an error if there is no such buffer." (write-back (org-src--goto-coordinates coordinates beg end)))) ;; Clean up left-over markers and restore window configuration. (set-marker beg nil) - (set-marker end nil) - (when org-src--saved-temp-window-config - (set-window-configuration org-src--saved-temp-window-config) - (setq org-src--saved-temp-window-config nil)))) + (set-marker end nil))) (provide 'org-src) From b3c40c32b6bd8618d417261a1b97514bcdbca1a9 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 30 Nov 2018 18:43:30 +0100 Subject: [PATCH 36/40] ox-latex: Extend LaTeX attributes and captions to "table.el" tables * lisp/ox-latex.el (org-latex--decorate-table): New function. (org-latex--org-table): Use new function. (org-latex--table.el-table): Use new function. --- etc/ORG-NEWS | 3 + lisp/ox-latex.el | 214 ++++++++++++++++++++++------------------------- 2 files changed, 103 insertions(+), 114 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 6b09cdc5b..046244788 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -42,6 +42,9 @@ See [[git:3367ac9457]] for details. ** New features *** Babel **** Add LaTeX output support in PlantUML +*** Allow LaTeX attributes and captions for "table.el" tables +Supported LaTeX attributes are ~:float~, ~:center~, ~:font~ and +~:caption~. *** Attach buffer contents to headline With == key from attachment dispatcher (==), it is now possible to write the contents of a buffer to a file in the headline diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index cae6900f4..1dec461d3 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -3184,6 +3184,58 @@ centered." info) (apply 'concat (nreverse align))))) +(defun org-latex--decorate-table (table attributes caption above? info) + "Decorate TABLE string with caption and float environment. + +ATTRIBUTES is the plist containing is LaTeX attributes. CAPTION +is its caption. It is located above the table if ABOVE? is +non-nil. INFO is the plist containing current export parameters. + +Return new environment, as a string." + (let* ((float-environment + (let ((float (plist-get attributes :float))) + (cond ((and (not float) (plist-member attributes :float)) nil) + ((member float '("sidewaystable" "sideways")) "sidewaystable") + ((equal float "multicolumn") "table*") + ((or float + (org-element-property :caption table) + (org-string-nw-p (plist-get attributes :caption))) + "table") + (t nil)))) + (placement + (or (plist-get attributes :placement) + (format "[%s]" (plist-get info :latex-default-figure-position)))) + (center? (if (plist-member attributes :center) + (plist-get attributes :center) + (plist-get info :latex-tables-centered))) + (fontsize (let ((font (plist-get attributes :font))) + (and font (concat font "\n"))))) + (concat (cond + (float-environment + (concat (format "\\begin{%s}%s\n" float-environment placement) + (if above? caption "") + (when center? "\\centering\n") + fontsize)) + (caption + (concat (and center? "\\begin{center}\n" ) + (if above? caption "") + (cond ((and fontsize center?) fontsize) + (fontsize (concat "{" fontsize)) + (t nil)))) + (center? (concat "\\begin{center}\n" fontsize)) + (fontsize (concat "{" fontsize))) + table + (cond + (float-environment + (concat (if above? "" (concat "\n" caption)) + (format "\n\\end{%s}" float-environment))) + (caption + (concat (if above? "" (concat "\n" caption)) + (and center? "\n\\end{center}") + (and fontsize (not center?) "}"))) + (center? "\n\\end{center}") + (fontsize "}"))))) + (defun org-latex--org-table (table contents info) "Return appropriate LaTeX code for an Org table. @@ -3193,109 +3245,44 @@ channel. This function assumes TABLE has `org' as its `:type' property and `table' as its `:mode' attribute." - (let* ((caption (org-latex--caption/label-string table info)) - (attr (org-export-read-attribute :attr_latex table)) - ;; Determine alignment string. + (let* ((attr (org-export-read-attribute :attr_latex table)) (alignment (org-latex--align-string table info)) - ;; Determine environment for the table: longtable, tabular... (table-env (or (plist-get attr :environment) (plist-get info :latex-default-table-environment))) - ;; If table is a float, determine environment: table, table* - ;; or sidewaystable. - (float-env (unless (member table-env '("longtable" "longtabu")) - (let ((float (plist-get attr :float))) - (cond - ((and (not float) (plist-member attr :float)) nil) - ((or (string= float "sidewaystable") - (string= float "sideways")) "sidewaystable") - ((string= float "multicolumn") "table*") - ((or float - (org-element-property :caption table) - (org-string-nw-p (plist-get attr :caption))) - "table"))))) - ;; Extract others display options. - (fontsize (let ((font (plist-get attr :font))) - (and font (concat font "\n")))) - ;; "tabular" environment doesn't allow to define a width. - (width (and (not (equal table-env "tabular")) (plist-get attr :width))) - (spreadp (plist-get attr :spread)) - (placement - (or (plist-get attr :placement) - (format "[%s]" (plist-get info :latex-default-figure-position)))) - (centerp (if (plist-member attr :center) (plist-get attr :center) - (plist-get info :latex-tables-centered))) - (caption-above-p (org-latex--caption-above-p table info))) - ;; Prepare the final format string for the table. + (width + (let ((w (plist-get attr :width))) + (cond ((not w) "") + ((member table-env '("tabular" "longtable")) "") + ((member table-env '("tabu" "longtabu")) + (format (if (plist-get attr :spread) " spread %s " + " to %s ") + w)) + (t (format "{%s}" w))))) + (caption (org-latex--caption/label-string table info)) + (above? (org-latex--caption-above-p table info))) (cond - ;; Longtable. - ((equal "longtable" table-env) - (concat (and fontsize (concat "{" fontsize)) - (format "\\begin{longtable}{%s}\n" alignment) - (and caption-above-p - (org-string-nw-p caption) - (concat caption "\\\\\n")) - contents - (and (not caption-above-p) - (org-string-nw-p caption) - (concat caption "\\\\\n")) - "\\end{longtable}\n" - (and fontsize "}"))) - ;; Longtabu - ((equal "longtabu" table-env) - (concat (and fontsize (concat "{" fontsize)) - (format "\\begin{longtabu}%s{%s}\n" - (if width - (format " %s %s " - (if spreadp "spread" "to") width) "") - alignment) - (and caption-above-p - (org-string-nw-p caption) - (concat caption "\\\\\n")) - contents - (and (not caption-above-p) - (org-string-nw-p caption) - (concat caption "\\\\\n")) - "\\end{longtabu}\n" - (and fontsize "}"))) - ;; Others. - (t (concat (cond - (float-env - (concat (format "\\begin{%s}%s\n" float-env placement) - (if caption-above-p caption "") - (when centerp "\\centering\n") - fontsize)) - ((and (not float-env) caption) - (concat - (and centerp "\\begin{center}\n" ) - (if caption-above-p caption "") - (cond ((and fontsize centerp) fontsize) - (fontsize (concat "{" fontsize))))) - (centerp (concat "\\begin{center}\n" fontsize)) - (fontsize (concat "{" fontsize))) - (cond ((equal "tabu" table-env) - (format "\\begin{tabu}%s{%s}\n%s\\end{tabu}" - (if width (format - (if spreadp " spread %s " " to %s ") - width) "") - alignment - contents)) - (t (format "\\begin{%s}%s{%s}\n%s\\end{%s}" - table-env - (if width (format "{%s}" width) "") - alignment - contents - table-env))) - (cond - (float-env - (concat (if caption-above-p "" (concat "\n" caption)) - (format "\n\\end{%s}" float-env))) - ((and (not float-env) caption) - (concat - (if caption-above-p "" (concat "\n" caption)) - (and centerp "\n\\end{center}") - (and fontsize (not centerp) "}"))) - (centerp "\n\\end{center}") - (fontsize "}"))))))) + ((member table-env '("longtable" "longtabu")) + (let ((fontsize (let ((font (plist-get attr :font))) + (and font (concat font "\n"))))) + (concat (and fontsize (concat "{" fontsize)) + (format "\\begin{%s}%s{%s}\n" table-env width alignment) + (and above? + (org-string-nw-p caption) + (concat caption "\\\\\n")) + contents + (and (not above?) + (org-string-nw-p caption) + (concat caption "\\\\\n")) + (format "\\end{%s}" table-env) + (and fontsize "}")))) + (t + (let ((output (format "\\begin{%s}%s{%s}\n%s\\end{%s}" + table-env + width + alignment + contents + table-env))) + (org-latex--decorate-table output attr caption above? info)))))) (defun org-latex--table.el-table (table info) "Return appropriate LaTeX code for a table.el table. @@ -3309,18 +3296,20 @@ property." ;; Ensure "*org-export-table*" buffer is empty. (with-current-buffer (get-buffer-create "*org-export-table*") (erase-buffer)) - (let ((output (with-temp-buffer - (insert (org-element-property :value table)) - (goto-char 1) - (re-search-forward "^[ \t]*|[^|]" nil t) - (table-generate-source 'latex "*org-export-table*") - (with-current-buffer "*org-export-table*" - (org-trim (buffer-string)))))) + (let ((output + (replace-regexp-in-string + "^%.*\n" "" ;remove comments + (with-temp-buffer + (save-excursion (insert (org-element-property :value table))) + (re-search-forward "^[ \t]*|[^|]" nil t) + (table-generate-source 'latex "*org-export-table*") + (with-current-buffer "*org-export-table*" + (org-trim (buffer-string)))) + t t))) (kill-buffer (get-buffer "*org-export-table*")) - ;; Remove left out comments. - (while (string-match "^%.*\n" output) - (setq output (replace-match "" t t output))) - (let ((attr (org-export-read-attribute :attr_latex table))) + (let ((attr (org-export-read-attribute :attr_latex table)) + (caption (org-latex--caption/label-string table info)) + (above? (org-latex--caption-above-p table info))) (when (plist-get attr :rmlines) ;; When the "rmlines" attribute is provided, remove all hlines ;; but the the one separating heading from the table body. @@ -3329,10 +3318,7 @@ property." (setq pos (string-match "^\\\\hline\n?" output pos))) (cl-incf n) (unless (= n 2) (setq output (replace-match "" nil nil output)))))) - (let ((centerp (if (plist-member attr :center) (plist-get attr :center) - (plist-get info :latex-tables-centered)))) - (if (not centerp) output - (format "\\begin{center}\n%s\n\\end{center}" output)))))) + (org-latex--decorate-table output attr caption above? info)))) (defun org-latex--math-table (table info) "Return appropriate LaTeX code for a matrix. From 4ef922861730adc7ba8d6193473eee32f61b28e8 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 30 Nov 2018 21:18:29 +0100 Subject: [PATCH 37/40] Silence byte-compiler --- lisp/org-keys.el | 1 + lisp/org.el | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lisp/org-keys.el b/lisp/org-keys.el index eeb3ff393..bed2f2ad4 100644 --- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -100,6 +100,7 @@ (declare-function org-goto-calendar "org" (&optional arg)) (declare-function org-inc-effort "org" ()) (declare-function org-increase-number-at-point "org" (&optional inc)) +(declare-function org-info-find-node "org" (&optional nodename)) (declare-function org-insert-all-links "org" (arg &optional pre post)) (declare-function org-insert-drawer "org" (&optional arg drawer)) (declare-function org-insert-heading-respect-content "org" (&optional invisible-ok)) diff --git a/lisp/org.el b/lisp/org.el index 0559f4871..c8790d75c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -198,6 +198,10 @@ Stars are put in group 1 and the trimmed body in group 2.") (declare-function org-table-justify-field-maybe "org-table" (&optional new)) (declare-function org-table-maybe-eval-formula "org-table" ()) (declare-function org-table-maybe-recalculate-line "org-table" ()) +(declare-function org-table-move-cell-up "org-table" ()) +(declare-function org-table-move-cell-down "org-table" ()) +(declare-function org-table-move-cell-right "org-table" ()) +(declare-function org-table-move-cell-left "org-table" ()) (declare-function org-table-next-row "org-table" ()) (declare-function org-table-paste-rectangle "org-table" ()) (declare-function org-table-recalculate "org-table" (&optional all noalign)) From df7b8cdf7001899b1fa0f4c3464d5d8572157ecb Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 2 Dec 2018 14:03:53 +0100 Subject: [PATCH 38/40] org-colview: Remove `org-columns-compact-links' * lisp/org-colview.el (org-columns--displayed-value): Use `org-link-display-format' instead. --- lisp/org-colview.el | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 5b3cf51e4..bc55f5f6b 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -247,7 +247,7 @@ display, as a string." (concat (make-string (1- (org-current-level)) (if org-hide-leading-stars ?\s ?*)) "* " - (org-columns-compact-links value))) + (org-link-display-format value))) (`(,_ ,_ ,_ ,_ nil) value) ;; If PRINTF is set, assume we are displaying a number and ;; obey to the format string. @@ -501,14 +501,6 @@ for the duration of the command.") (when (local-variable-p 'org-colview-initial-truncate-line-value) (setq truncate-lines org-colview-initial-truncate-line-value)))) -(defun org-columns-compact-links (s) - "Replace [[link][desc]] with [desc] or [link]." - (while (string-match org-bracket-link-regexp s) - (setq s (replace-match - (concat "[" (match-string (if (match-end 3) 3 1) s) "]") - t t s))) - s) - (defun org-columns-show-value () "Show the full value of the property." (interactive) From 6f8347a834cdd3c4b514e1482e424f33c01606c0 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 2 Dec 2018 14:49:02 +0100 Subject: [PATCH 39/40] org-clock: Use `org-link-display-format' * lisp/org-clock.el (org-clock--mode-line-heading): Use `org-link-display-format'. --- lisp/org-clock.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 0f146ee43..9e4ca8967 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -522,8 +522,7 @@ cannot be translated." (cond ((functionp org-clock-heading-function) (funcall org-clock-heading-function)) ((org-before-first-heading-p) "???") - (t (replace-regexp-in-string - org-bracket-link-analytic-regexp "\\5" + (t (org-link-display-format (org-no-properties (org-get-heading t t t t)))))) (defun org-clock-menu () From 94d2dbf95fdb711f224ce6870d6b9552cc609414 Mon Sep 17 00:00:00 2001 From: Jens Lechtenboerger Date: Sun, 2 Dec 2018 20:25:38 +0100 Subject: [PATCH 40/40] ox-html: New property HTML_HEADLINE_CLASS for class of headline * lisp/ox-html.el (org-html-headline): Add new property HTML_HEADLINE_CLASS to assign class attribute to headline. * doc/org-manual.org (CSS support): Document new property HTML_HEADLINE_CLASS. --- doc/org-manual.org | 4 +++- etc/ORG-NEWS | 3 +++ lisp/ox-html.el | 9 +++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index b5b071386..231315a32 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -12813,10 +12813,12 @@ around them. Both of these approaches can avoid referring to an external file. #+cindex: @samp{HTML_CONTAINER_CLASS}, property +#+cindex: @samp{HTML_HEADLINE_CLASS}, property In order to add styles to a sub-tree, use the =HTML_CONTAINER_CLASS= property to assign a class to the tree. In order to specify CSS styles for a particular headline, you can use the ID specified in -a =CUSTOM_ID= property. +a =CUSTOM_ID= property. You can also assign a specific class to +a headline with the =HTML_HEADLINE_CLASS= property. Never change the ~org-html-style-default~ constant. Instead use other simpler ways of customizing as described above. diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 046244788..f9bea4b56 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -42,6 +42,9 @@ See [[git:3367ac9457]] for details. ** New features *** Babel **** Add LaTeX output support in PlantUML +*** New property =HTML_HEADLINE_CLASS= in HTML export +The new property =HTML_HEADLINE_CLASS= assigns a class attribute to +a headline. *** Allow LaTeX attributes and captions for "table.el" tables Supported LaTeX attributes are ~:float~, ~:center~, ~:font~ and ~:caption~. diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 6a81be126..7c836f155 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2607,7 +2607,10 @@ holding contextual information." (and (org-export-last-sibling-p headline info) (format "\n" html-type)))) ;; Standard headline. Export it as a section. - (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline)) + (let ((extra-class + (org-element-property :HTML_CONTAINER_CLASS headline)) + (headline-class + (org-element-property :HTML_HEADLINE_CLASS headline)) (first-content (car (org-element-contents headline)))) (format "<%s id=\"%s\" class=\"%s\">%s%s\n" (org-html--container headline info) @@ -2616,9 +2619,11 @@ holding contextual information." (concat (format "outline-%d" level) (and extra-class " ") extra-class) - (format "\n%s\n" + (format "\n%s\n" level id + (if (not headline-class) "" + (format " class=\"%s\"" headline-class)) (concat (and numberedp (format