diff --git a/doc/org.texi b/doc/org.texi index 9c1f635e7..dee46d105 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -17029,8 +17029,6 @@ More templates can added by customizing the variable @node Speed keys @section Speed keys @cindex speed keys -@vindex org-use-speed-commands -@vindex org-speed-commands-user Single keystrokes can execute custom commands in an Org file when the cursor is on a headline. Without the extra burden of a meta or modifier key, Speed @@ -17039,14 +17037,19 @@ navigation, Speed Keys may come in handy on small mobile devices that do not have full keyboards. Speed Keys may also work on TTY devices known for their problems when entering Emacs keychords. -By default, Org has Speed Keys disabled. To activate Speed Keys, configure -the variable @code{org-use-speed-commands}. To trigger a Speed Key, the -cursor must be at the beginning of an Org headline, before any of the stars. +@vindex org-use-speed-commands +By default, Org has Speed Keys disabled. To activate Speed Keys, set the +variable @code{org-use-speed-commands} to a non-@code{nil} value. To trigger +a Speed Key, the cursor must be at the beginning of an Org headline, before +any of the stars. -Org comes with a pre-defined list of Speed Keys; @kbd{?} shows currently -active Speed Keys. To add or modify Speed Keys, customize the variable, -@code{org-speed-commands-user}. For more details, see the variable's -docstring. +@vindex org-speed-commands-user +@findex org-speed-command-help +Org comes with a pre-defined list of Speed Keys. To add or modify Speed +Keys, customize the variable, @code{org-speed-commands-user}. For more +details, see the variable's docstring. With Speed Keys activated, @kbd{M-x +org-speed-command-help}, or @kbd{?} when cursor is at the beginning of an Org +headline, shows currently active Speed Keys, including the user-defined ones. @node Code evaluation security diff --git a/lisp/org-element.el b/lisp/org-element.el index c60a56ead..b2e4aedec 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -878,14 +878,14 @@ Assume point is at the beginning of the footnote definition." (match-string-no-properties 1))) (begin (car affiliated)) (post-affiliated (point)) - (ending + (end (save-excursion (end-of-line) (cond ((not (re-search-forward org-element--footnote-separator limit t)) limit) - ((eq (char-after (match-beginning 0)) ?\[) + ((eq ?\[ (char-after (match-beginning 0))) ;; At a new footnote definition, make sure we end ;; before any affiliated keyword above. (forward-line -1) @@ -893,26 +893,27 @@ Assume point is at the beginning of the footnote definition." (looking-at-p org-element--affiliated-re)) (forward-line -1)) (line-beginning-position 2)) - (t (match-beginning 0))))) + ((eq ?* (char-after (match-beginning 0))) (match-beginning 0)) + (t (skip-chars-forward " \r\t\n" limit) + (if (= limit (point)) limit (line-beginning-position)))))) (contents-begin - (progn - (search-forward "]") - (skip-chars-forward " \r\t\n" ending) - (cond ((= (point) ending) nil) - ((= (line-beginning-position) post-affiliated) (point)) - (t (line-beginning-position))))) - (contents-end (and contents-begin ending)) - (end (progn (goto-char ending) - (skip-chars-forward " \r\t\n" limit) - (if (eobp) (point) (line-beginning-position))))) + (progn (search-forward "]") + (skip-chars-forward " \r\t\n" end) + (cond ((= (point) end) nil) + ((= (line-beginning-position) post-affiliated) (point)) + (t (line-beginning-position))))) + (contents-end + (progn (goto-char end) + (skip-chars-backward " \r\t\n") + (line-beginning-position 2)))) (list 'footnote-definition (nconc (list :label label :begin begin :end end :contents-begin contents-begin - :contents-end contents-end - :post-blank (count-lines ending end) + :contents-end (and contents-begin contents-end) + :post-blank (count-lines contents-end end) :post-affiliated post-affiliated) (cdr affiliated)))))) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index a96d35a96..5a4c885a5 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -919,20 +919,21 @@ Some other text "Test `footnote-definition' parser." (should (org-test-with-temp-text "[fn:1] Definition" - (org-element-map (org-element-parse-buffer) 'footnote-definition - 'identity nil t))) - ;; Footnote with more contents + (eq (org-element-type (org-element-at-point)) 'footnote-definition))) + ;; Footnote with more contents. (should - (= 29 - (org-element-property - :end - (org-test-with-temp-text "[fn:1] Definition\n\n| a | b |" - (org-element-map (org-element-parse-buffer) 'footnote-definition - 'identity nil t))))) + (= 29 (org-test-with-temp-text "[fn:1] Definition\n\n| a | b |" + (org-element-property :end (org-element-at-point))))) + ;; Test difference between :contents-end and :end property + (should + (< (org-test-with-temp-text "[fn:1] Definition\n\n\n" + (org-element-property :contents-end (org-element-at-point))) + (org-test-with-temp-text "[fn:1] Definition\n\n\n" + (org-element-property :end (org-element-at-point))))) ;; Footnote starting with special syntax. (should-not - (org-test-with-temp-text "[fn:1] - no item" - (org-element-map (org-element-parse-buffer) 'item 'identity))) + (org-test-with-temp-text "[fn:1] - no item" + (eq (org-element-type (org-element-at-point)) 'item))) ;; Correctly handle footnote starting with an empty line. (should (= 9 @@ -952,7 +953,13 @@ Some other text (should (org-test-with-temp-text "[fn:1] 1\n\n#+attr_latex: :offset 0in\n[fn:2] 2" (goto-char (org-element-property :end (org-element-at-point))) - (looking-at "#")))) + (looking-at "#"))) + ;; An empty footnote has no contents. + (should-not + (org-test-with-temp-text "[fn:1]\n\n" + (let ((footnote (org-element-at-point))) + (or (org-element-property :contents-begin footnote) + (org-element-property :contents-end footnote)))))) ;;;; Footnotes Reference.