org-src: Refuse to edit remotely inline footnotes

* lisp/org-src.el (org-edit-footnote-reference): Throw an error when
  definition is inline.
This commit is contained in:
Nicolas Goaziou 2015-04-26 14:57:36 +02:00
parent ca2b398396
commit 9d4b3e356f
1 changed files with 33 additions and 34 deletions

View File

@ -681,41 +681,40 @@ If BUFFER is non-nil, test it instead."
"Edit definition of footnote reference at point." "Edit definition of footnote reference at point."
(interactive) (interactive)
(let ((context (org-element-context))) (let ((context (org-element-context)))
(cond ((not (and (eq (org-element-type context) 'footnote-reference) (unless (and (eq (org-element-type context) 'footnote-reference)
(< (point) (< (point)
(org-with-wide-buffer
(goto-char (org-element-property :end context))
(skip-chars-backward " \t")
(point)))))
(user-error "Not on a footnote reference"))
((eq (org-element-property :type context) 'inline)
(user-error "Cannot edit inline footnotes"))
(t
(let* ((label (org-element-property :label context))
(definition
(org-with-wide-buffer (org-with-wide-buffer
(org-footnote-goto-definition label) (goto-char (org-element-property :end context))
(beginning-of-line) (skip-chars-backward " \t")
(org-element-at-point)))) (point))))
(org-src--edit-element (user-error "Not on a footnote reference"))
definition (format "*Edit footnote [%s]*" label) (let* ((label (org-element-property :label context))
#'org-mode (definition
(lambda () (delete-region (point) (search-forward "]"))) (org-with-wide-buffer
(concat (org-footnote-goto-definition label)
(org-propertize (format "[%s]" label) (beginning-of-line)
'read-only "Cannot edit footnote label" (org-element-at-point))))
'front-sticky t (unless (eq (org-element-type definition) 'footnote-definition)
'rear-nonsticky t) (user-error "Cannot edit remotely inline footnotes"))
(org-with-wide-buffer (org-src--edit-element
(buffer-substring-no-properties definition (format "*Edit footnote [%s]*" label)
(progn #'org-mode
(goto-char (org-element-property :contents-begin definition)) (lambda () (delete-region (point) (search-forward "]")))
(skip-chars-backward " \r\t\n") (concat
(point)) (org-propertize (format "[%s]" label)
(org-element-property :contents-end definition)))) 'read-only "Cannot edit footnote label"
'remote)) 'front-sticky t
;; Report success. 'rear-nonsticky t)
t)))) (org-with-wide-buffer
(buffer-substring-no-properties
(progn
(goto-char (org-element-property :contents-begin definition))
(skip-chars-backward " \r\t\n")
(point))
(org-element-property :contents-end definition))))
'remote))
;; Report success.
t))
(defun org-edit-table.el () (defun org-edit-table.el ()
"Edit \"table.el\" table at point. "Edit \"table.el\" table at point.