diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2014-11-11 17:31:40 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2014-11-22 20:59:08 +0100 |
commit | 9c06f8cce93f479bff5ef053777c235935717a66 (patch) | |
tree | 37e07f492d4e67a8e8887238f455d8e649c7f319 | |
parent | 3953cb19b4a907c620bd6260348ee8a6396646b1 (diff) | |
download | org-mode-9c06f8cce93f479bff5ef053777c235935717a66.tar.gz |
org-src: Remove unused functions and variables
* lisp/org-src.el (org-edit-src-region-extra): Remove variable.
(org-edit-src-find-region-and-lang, org-edit-src-get-lang,
org-edit-src-get-label-format, org-edit-src-get-indentation,
org-src-fontify-block, org-src-fontify-buffer): Remove functions.
(org-src-font-lock-fontify-block): Remove reference to removed
function in docstring.
Remove all functions and variables related to parsing, which is now
delegated to org-element.el. Also reorder a defcustom and
a declaration in the library.
-rw-r--r-- | lisp/org-src.el | 143 |
1 files changed, 11 insertions, 132 deletions
diff --git a/lisp/org-src.el b/lisp/org-src.el index d774e6e..20819d6 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -46,22 +46,7 @@ "org-compat" (&optional buffer-or-name norecord label)) (declare-function org-base-buffer "org" (buffer)) -(defcustom org-edit-src-region-extra nil - "Additional regexps to identify regions for editing with `org-edit-src-code'. -For examples see the function `org-edit-src-find-region-and-lang'. -The regular expression identifying the begin marker should end with a newline, -and the regexp marking the end line should start with a newline, to make sure -there are kept outside the narrowed region." - :group 'org-edit-structure - :type '(repeat - (list - (regexp :tag "begin regexp") - (regexp :tag "end regexp") - (choice :tag "language" - (string :tag "specify") - (integer :tag "from match group") - (const :tag "from `lang' element") - (const :tag "from `style' element"))))) +(declare-function org-babel-tangle "ob-tangle" (&optional arg target-file lang)) (defcustom org-edit-src-turn-on-auto-save nil "Non-nil means turn `auto-save-mode' on when editing a source block. @@ -194,6 +179,13 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is (string "Language name") (symbol "Major mode")))) +(defcustom org-src-tab-acts-natively nil + "If non-nil, the effect of TAB in a code block is as if it were +issued in the language major mode buffer." + :type 'boolean + :version "24.1" + :group 'org-babel) + ;;; Editing source examples (defvar org-src-mode-map (make-sparse-keymap)) @@ -211,6 +203,8 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is (defvar org-edit-src-block-indentation nil) (defvar org-edit-src-saved-temp-window-config nil) +(defvar org-src-babel-info nil) + (defcustom org-src-ask-before-returning-to-edit-buffer t "If nil, when org-edit-src code is used on a block that already has an active edit buffer, it will switch to that edit buffer @@ -221,8 +215,6 @@ the existing edit buffer." :package-version '(Org . "8.0") :type 'boolean) -(defvar org-src-babel-info nil) - (define-minor-mode org-src-mode "Minor mode for language major mode buffers generated by org. This minor mode is turned on in two situations: @@ -546,94 +538,6 @@ the fragment in the Org-mode buffer." (message "%s" msg) t))) -(defun org-edit-src-find-region-and-lang () - "Find the region and language for a local edit. -Return a list with beginning and end of the region, a string representing -the language, a switch telling if the content should be in a single line." - (let ((re-list - (append - org-edit-src-region-extra - '( - ("^[ \t]*#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n[ \t]*#\\+end_src" 2) - ("^[ \t]*#\\+begin_example.*\n" "\n[ \t]*#\\+end_example" "fundamental") - ("^[ \t]*#\\+html:" "\n" "html" single-line) - ("^[ \t]*#\\+begin_html.*\n" "\n[ \t]*#\\+end_html" "html") - ("^[ \t]*#\\+latex:" "\n" "latex" single-line) - ("^[ \t]*#\\+begin_latex.*\n" "\n[ \t]*#\\+end_latex" "latex") - ("^[ \t]*#\\+ascii:" "\n" "fundamental" single-line) - ("^[ \t]*#\\+begin_ascii.*\n" "\n[ \t]*#\\+end_ascii" "fundamental") - ("^[ \t]*#\\+macro:[ \t]+\\S-+\\( \\|$\\)" - "\n" "fundamental" macro-definition) - ))) - (pos (point)) - re1 re2 single beg end lang lfmt match-re1 ind entry) - (catch 'exit - (while (setq entry (pop re-list)) - (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry) - single (nth 3 entry)) - (save-excursion - (if (or (looking-at re1) - (re-search-backward re1 nil t)) - (progn - (setq match-re1 (match-string 0)) - (setq beg (match-end 0) - lang (org-edit-src-get-lang lang) - lfmt (org-edit-src-get-label-format match-re1) - ind (org-edit-src-get-indentation (match-beginning 0))) - (if (and (re-search-forward re2 nil t) - (>= (match-end 0) pos)) - (throw 'exit (list beg (match-beginning 0) - lang single lfmt ind)))) - (if (or (looking-at re2) - (re-search-forward re2 nil t)) - (progn - (setq end (match-beginning 0)) - (if (and (re-search-backward re1 nil t) - (<= (match-beginning 0) pos)) - (progn - (setq lfmt (org-edit-src-get-label-format - (match-string 0)) - ind (org-edit-src-get-indentation - (match-beginning 0))) - (throw 'exit - (list (match-end 0) end - (org-edit-src-get-lang lang) - single lfmt ind))))))))) - (when (org-at-table.el-p) - (re-search-backward "^[\t]*[^ \t|\\+]" nil t) - (setq beg (1+ (point-at-eol))) - (goto-char beg) - (or (re-search-forward "^[\t]*[^ \t|\\+]" nil t) - (progn (goto-char (point-max)) (newline))) - (setq end (1- (point-at-bol))) - (throw 'exit (list beg end 'table.el nil nil 0)))))) - -(defun org-edit-src-get-lang (lang) - "Extract the src language." - (let ((m (match-string 0))) - (cond - ((stringp lang) lang) - ((integerp lang) (match-string lang)) - ((and (eq lang 'lang) - (string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m)) - (match-string 1 m)) - ((and (eq lang 'style) - (string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m)) - (match-string 1 m)) - (t "fundamental")))) - -(defun org-edit-src-get-label-format (s) - "Extract the label format." - (save-match-data - (if (string-match "-l[ \t]+\\\\?\"\\([^\t\r\n\"]+\\)\\\\?\"" s) - (match-string 1 s)))) - -(defun org-edit-src-get-indentation (pos) - "Count leading whitespace characters on line." - (save-match-data - (goto-char pos) - (org-get-indentation))) - (defun org-escape-code-in-region (beg end) "Escape lines between BEG and END. Escaping happens when a line starts with \"*\", \"#+\", \",*\" or @@ -799,8 +703,6 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." (user-error "Use C-c ' to save and exit, C-c C-k to abort editing") (org-src-in-org-buffer (save-buffer)))) -(declare-function org-babel-tangle "ob-tangle" (&optional arg target-file lang)) - (defun org-src-tangle (arg) "Tangle the parent buffer." (interactive) @@ -875,19 +777,10 @@ Org-babel commands." (call-interactively (lookup-key org-babel-map key))))) -(defcustom org-src-tab-acts-natively nil - "If non-nil, the effect of TAB in a code block is as if it were -issued in the language major mode buffer." - :type 'boolean - :version "24.1" - :group 'org-babel) - (defun org-src-font-lock-fontify-block (lang start end) "Fontify code block. This function is called by emacs automatic fontification, as long -as `org-src-fontify-natively' is non-nil. For manual -fontification of code blocks see `org-src-fontify-block' and -`org-src-fontify-buffer'" +as `org-src-fontify-natively' is non-nil." (let ((lang-mode (org-src-get-lang-mode lang))) (if (fboundp lang-mode) (let ((string (buffer-substring-no-properties start end)) @@ -912,20 +805,6 @@ fontification of code blocks see `org-src-fontify-block' and '(font-lock-fontified t fontified t font-lock-multiline t)) (set-buffer-modified-p modified))))) -(defun org-src-fontify-block () - "Fontify code block at point." - (interactive) - (save-excursion - (let ((org-src-fontify-natively t) - (info (org-edit-src-find-region-and-lang))) - (font-lock-fontify-region (nth 0 info) (nth 1 info))))) - -(defun org-src-fontify-buffer () - "Fontify all code blocks in the current buffer." - (interactive) - (org-babel-map-src-blocks nil - (org-src-fontify-block))) - (defun org-src-get-lang-mode (lang) "Return major mode that should be used for LANG. LANG is a string, and the returned major mode is a symbol." |