mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 11:02:53 +00:00
Make "C-c '" also edit #+MACRO definitions, including multiline
This commit is contained in:
parent
e72df7e2e4
commit
e59e619a8f
|
@ -1,5 +1,9 @@
|
||||||
2009-10-06 Carsten Dominik <carsten.dominik@gmail.com>
|
2009-10-06 Carsten Dominik <carsten.dominik@gmail.com>
|
||||||
|
|
||||||
|
* org-src.el (org-edit-src-code)
|
||||||
|
(org-edit-src-find-region-and-lang, org-edit-src-exit): Handle
|
||||||
|
macro editing.
|
||||||
|
|
||||||
* org-agenda.el (org-prefix-category-max-length): New variable.
|
* org-agenda.el (org-prefix-category-max-length): New variable.
|
||||||
(org-format-agenda-item): Use `org-prefix-category-max-length'.
|
(org-format-agenda-item): Use `org-prefix-category-max-length'.
|
||||||
(org-compile-prefix-format): Set `org-prefix-category-max-length'.
|
(org-compile-prefix-format): Set `org-prefix-category-max-length'.
|
||||||
|
|
|
@ -199,6 +199,8 @@ the edited version."
|
||||||
map))
|
map))
|
||||||
(org-overlay-put ovl :read-only "Leave me alone")
|
(org-overlay-put ovl :read-only "Leave me alone")
|
||||||
(switch-to-buffer buffer)
|
(switch-to-buffer buffer)
|
||||||
|
(if (eq single 'macro-definition)
|
||||||
|
(setq code (replace-regexp-in-string "\\\\n" "\n" code t t)))
|
||||||
(insert code)
|
(insert code)
|
||||||
(remove-text-properties (point-min) (point-max)
|
(remove-text-properties (point-min) (point-max)
|
||||||
'(display nil invisible nil intangible nil))
|
'(display nil invisible nil intangible nil))
|
||||||
|
@ -360,6 +362,8 @@ the language, a switch telling of the content should be in a single line."
|
||||||
("^[ \t]*#\\+ascii:" "\n" "fundamental" single-line)
|
("^[ \t]*#\\+ascii:" "\n" "fundamental" single-line)
|
||||||
("^[ \t]*#\\+begin_ascii.*\n" "\n[ \t]*#\\+end_ascii" "fundamental")
|
("^[ \t]*#\\+begin_ascii.*\n" "\n[ \t]*#\\+end_ascii" "fundamental")
|
||||||
("^[ \t]*#\\+docbook:" "\n" "xml" single-line)
|
("^[ \t]*#\\+docbook:" "\n" "xml" single-line)
|
||||||
|
("^[ \t]*#\\+macro:[ \t]+\\S-+\\( \\|$\\)"
|
||||||
|
"\n" "fundamental" macro-definition)
|
||||||
("^[ \t]*#\\+begin_docbook.*\n" "\n[ \t]*#\\+end_docbook" "xml")
|
("^[ \t]*#\\+begin_docbook.*\n" "\n[ \t]*#\\+end_docbook" "xml")
|
||||||
)))
|
)))
|
||||||
(pos (point))
|
(pos (point))
|
||||||
|
@ -428,28 +432,35 @@ the language, a switch telling of the content should be in a single line."
|
||||||
(interactive)
|
(interactive)
|
||||||
(unless org-edit-src-from-org-mode
|
(unless org-edit-src-from-org-mode
|
||||||
(error "This is not a sub-editing buffer, something is wrong..."))
|
(error "This is not a sub-editing buffer, something is wrong..."))
|
||||||
(let ((beg org-edit-src-beg-marker)
|
(let* ((beg org-edit-src-beg-marker)
|
||||||
(end org-edit-src-end-marker)
|
(end org-edit-src-end-marker)
|
||||||
(ovl org-edit-src-overlay)
|
(ovl org-edit-src-overlay)
|
||||||
(buffer (current-buffer))
|
(buffer (current-buffer))
|
||||||
|
(single (org-bound-and-true-p org-edit-src-force-single-line))
|
||||||
|
(macro (eq single 'macro-definition))
|
||||||
(nindent org-edit-src-nindent)
|
(nindent org-edit-src-nindent)
|
||||||
code line)
|
code line)
|
||||||
(untabify (point-min) (point-max))
|
(untabify (point-min) (point-max))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if (looking-at "[ \t\n]*\n") (replace-match ""))
|
(if (looking-at "[ \t\n]*\n") (replace-match ""))
|
||||||
(if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match "")))
|
(unless macro
|
||||||
|
(if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))))
|
||||||
(setq line (if (org-bound-and-true-p org-edit-src-force-single-line)
|
(setq line (if (org-bound-and-true-p org-edit-src-force-single-line)
|
||||||
1
|
1
|
||||||
(org-current-line)))
|
(org-current-line)))
|
||||||
(when (org-bound-and-true-p org-edit-src-force-single-line)
|
(when single
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
(if (re-search-forward "\\s-+\\'" nil t) (replace-match ""))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(let ((cnt 0))
|
||||||
(while (re-search-forward "\n" nil t)
|
(while (re-search-forward "\n" nil t)
|
||||||
(replace-match " "))
|
(setq cnt (1+ cnt))
|
||||||
|
(replace-match (if macro "\\n" " ") t t))
|
||||||
|
(when (and macro (> cnt 0))
|
||||||
|
(goto-char (point-max)) (insert "\\n")))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if (looking-at "\\s-*") (replace-match " "))
|
(if (looking-at "\\s-*") (replace-match " ")))
|
||||||
(if (re-search-forward "\\s-+\\'" nil t)
|
|
||||||
(replace-match "")))
|
|
||||||
(when (org-bound-and-true-p org-edit-src-from-org-mode)
|
(when (org-bound-and-true-p org-edit-src-from-org-mode)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward
|
(while (re-search-forward
|
||||||
|
@ -460,7 +471,7 @@ the language, a switch telling of the content should be in a single line."
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward "^" nil t)
|
(while (re-search-forward "^" nil t)
|
||||||
(replace-match ": ")))
|
(replace-match ": ")))
|
||||||
(when nindent
|
(when (and nindent (not single))
|
||||||
(setq nindent (make-string (+ org-edit-src-content-indentation nindent)
|
(setq nindent (make-string (+ org-edit-src-content-indentation nindent)
|
||||||
?\ ))
|
?\ ))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
@ -474,6 +485,7 @@ the language, a switch telling of the content should be in a single line."
|
||||||
(delete-region beg end)
|
(delete-region beg end)
|
||||||
(insert code)
|
(insert code)
|
||||||
(goto-char beg)
|
(goto-char beg)
|
||||||
|
(if single (just-one-space))
|
||||||
(org-goto-line (1- (+ (org-current-line) line)))
|
(org-goto-line (1- (+ (org-current-line) line)))
|
||||||
(move-marker beg nil)
|
(move-marker beg nil)
|
||||||
(move-marker end nil)))
|
(move-marker end nil)))
|
||||||
|
|
Loading…
Reference in a new issue