diff options
| author | Bastien Guerry | 2013-01-08 15:27:18 +0100 |
|---|---|---|
| committer | Bastien Guerry | 2013-01-08 15:27:18 +0100 |
| commit | c7cf0ebc24d66371c8d48ad72f65e72a2a027f06 (patch) | |
| tree | dc95a8d996cf93343213c03668485a8750182648 /lisp/org/org-src.el | |
| parent | 06364e6463b654038ca3290fec6a37d1ca69700c (diff) | |
| download | emacs-c7cf0ebc24d66371c8d48ad72f65e72a2a027f06.tar.gz emacs-c7cf0ebc24d66371c8d48ad72f65e72a2a027f06.zip | |
Merge Org 7.9.3 (commit 31c1aea)
Diffstat (limited to 'lisp/org/org-src.el')
| -rw-r--r-- | lisp/org/org-src.el | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index 6dbf6d67fc5..221ae367c87 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el | |||
| @@ -39,6 +39,8 @@ | |||
| 39 | 39 | ||
| 40 | (declare-function org-do-remove-indentation "org" (&optional n)) | 40 | (declare-function org-do-remove-indentation "org" (&optional n)) |
| 41 | (declare-function org-at-table.el-p "org" ()) | 41 | (declare-function org-at-table.el-p "org" ()) |
| 42 | (declare-function org-in-src-block-p "org" (&optional inside)) | ||
| 43 | (declare-function org-in-block-p "org" (names)) | ||
| 42 | (declare-function org-get-indentation "org" (&optional line)) | 44 | (declare-function org-get-indentation "org" (&optional line)) |
| 43 | (declare-function org-switch-to-buffer-other-window "org" (&rest args)) | 45 | (declare-function org-switch-to-buffer-other-window "org" (&rest args)) |
| 44 | (declare-function org-pop-to-buffer-same-window | 46 | (declare-function org-pop-to-buffer-same-window |
| @@ -201,41 +203,39 @@ There is a mode hook, and keybindings for `org-edit-src-exit' and | |||
| 201 | `org-edit-src-save'") | 203 | `org-edit-src-save'") |
| 202 | 204 | ||
| 203 | (defun org-edit-src-code (&optional context code edit-buffer-name) | 205 | (defun org-edit-src-code (&optional context code edit-buffer-name) |
| 204 | "Edit the source CODE example at point. | 206 | "Edit the source CODE block at point. |
| 205 | The example is copied to a separate buffer, and that buffer is | 207 | The code is copied to a separate buffer and the appropriate mode |
| 206 | switched to the correct language mode. When done, exit with | 208 | is turned on. When done, exit with \\[org-edit-src-exit]. This will |
| 207 | \\[org-edit-src-exit]. This will remove the original code in the | 209 | remove the original code in the Org buffer, and replace it with the |
| 208 | Org buffer, and replace it with the edited version. An optional | 210 | edited version. An optional argument CONTEXT is used by \\[org-edit-src-save] |
| 209 | argument CONTEXT is used by \\[org-edit-src-save] when calling | 211 | when calling this function. See `org-src-window-setup' to configure |
| 210 | this function. See `org-src-window-setup' to configure the | 212 | the display of windows containing the Org buffer and the code buffer." |
| 211 | display of windows containing the Org buffer and the code | ||
| 212 | buffer." | ||
| 213 | (interactive) | 213 | (interactive) |
| 214 | (unless (eq context 'save) | 214 | (if (not (org-in-block-p '("src" "example" "latex" "html"))) |
| 215 | (setq org-edit-src-saved-temp-window-config (current-window-configuration))) | 215 | (user-error "Not in a source code or example block") |
| 216 | (let* ((mark (and (org-region-active-p) (mark))) | 216 | (unless (eq context 'save) |
| 217 | (case-fold-search t) | 217 | (setq org-edit-src-saved-temp-window-config (current-window-configuration))) |
| 218 | (info | 218 | (let* ((mark (and (org-region-active-p) (mark))) |
| 219 | ;; If the src region consists in no lines, we insert a blank | 219 | (case-fold-search t) |
| 220 | ;; line. | 220 | (info |
| 221 | (let* ((temp (org-edit-src-find-region-and-lang)) | 221 | ;; If the src region consists in no lines, we insert a blank |
| 222 | (beg (nth 0 temp)) | 222 | ;; line. |
| 223 | (end (nth 1 temp))) | 223 | (let* ((temp (org-edit-src-find-region-and-lang)) |
| 224 | (if (>= end beg) temp | 224 | (beg (nth 0 temp)) |
| 225 | (goto-char beg) | 225 | (end (nth 1 temp))) |
| 226 | (insert "\n") | 226 | (if (>= end beg) temp |
| 227 | (org-edit-src-find-region-and-lang)))) | 227 | (goto-char beg) |
| 228 | (full-info (org-babel-get-src-block-info 'light)) | 228 | (insert "\n") |
| 229 | (org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive | 229 | (org-edit-src-find-region-and-lang)))) |
| 230 | (beg (make-marker)) | 230 | (full-info (org-babel-get-src-block-info 'light)) |
| 231 | ;; Move marker with inserted text for case when src block is | 231 | (org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive |
| 232 | ;; just one empty line, i.e. beg == end. | 232 | (beg (make-marker)) |
| 233 | (end (copy-marker nil t)) | 233 | ;; Move marker with inserted text for case when src block is |
| 234 | (allow-write-back-p (null code)) | 234 | ;; just one empty line, i.e. beg == end. |
| 235 | block-nindent total-nindent ovl lang lang-f single lfmt buffer msg | 235 | (end (copy-marker (make-marker) t)) |
| 236 | begline markline markcol line col transmitted-variables) | 236 | (allow-write-back-p (null code)) |
| 237 | (if (not info) | 237 | block-nindent total-nindent ovl lang lang-f single lfmt buffer msg |
| 238 | nil | 238 | begline markline markcol line col transmitted-variables) |
| 239 | (setq beg (move-marker beg (nth 0 info)) | 239 | (setq beg (move-marker beg (nth 0 info)) |
| 240 | end (move-marker end (nth 1 info)) | 240 | end (move-marker end (nth 1 info)) |
| 241 | msg (if allow-write-back-p | 241 | msg (if allow-write-back-p |
| @@ -244,7 +244,7 @@ buffer." | |||
| 244 | "Exit with C-c ' (C-c and single quote)") | 244 | "Exit with C-c ' (C-c and single quote)") |
| 245 | code (or code (buffer-substring-no-properties beg end)) | 245 | code (or code (buffer-substring-no-properties beg end)) |
| 246 | lang (or (cdr (assoc (nth 2 info) org-src-lang-modes)) | 246 | lang (or (cdr (assoc (nth 2 info) org-src-lang-modes)) |
| 247 | (nth 2 info)) | 247 | (nth 2 info)) |
| 248 | lang (if (symbolp lang) (symbol-name lang) lang) | 248 | lang (if (symbolp lang) (symbol-name lang) lang) |
| 249 | single (nth 3 info) | 249 | single (nth 3 info) |
| 250 | block-nindent (nth 5 info) | 250 | block-nindent (nth 5 info) |
| @@ -633,7 +633,8 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." | |||
| 633 | (unless (org-bound-and-true-p org-edit-src-from-org-mode) | 633 | (unless (org-bound-and-true-p org-edit-src-from-org-mode) |
| 634 | (error "This is not a sub-editing buffer, something is wrong")) | 634 | (error "This is not a sub-editing buffer, something is wrong")) |
| 635 | (widen) | 635 | (widen) |
| 636 | (let* ((beg org-edit-src-beg-marker) | 636 | (let* ((fixed-width-p (string-match "Fixed Width" (buffer-name))) |
| 637 | (beg org-edit-src-beg-marker) | ||
| 637 | (end org-edit-src-end-marker) | 638 | (end org-edit-src-end-marker) |
| 638 | (ovl org-edit-src-overlay) | 639 | (ovl org-edit-src-overlay) |
| 639 | (bufstr (buffer-string)) | 640 | (bufstr (buffer-string)) |
| @@ -670,7 +671,8 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." | |||
| 670 | (goto-char (point-max)) (insert "\\n"))) | 671 | (goto-char (point-max)) (insert "\\n"))) |
| 671 | (goto-char (point-min)) | 672 | (goto-char (point-min)) |
| 672 | (if (looking-at "\\s-*") (replace-match " "))) | 673 | (if (looking-at "\\s-*") (replace-match " "))) |
| 673 | (when (org-bound-and-true-p org-edit-src-from-org-mode) | 674 | (when (and (org-bound-and-true-p org-edit-src-from-org-mode) |
| 675 | (not fixed-width-p)) | ||
| 674 | (org-escape-code-in-region (point-min) (point-max)) | 676 | (org-escape-code-in-region (point-min) (point-max)) |
| 675 | (setq delta (+ delta | 677 | (setq delta (+ delta |
| 676 | (save-excursion | 678 | (save-excursion |