forked from mirrors/org-mode
ob-tangle: Use lexical binding
* lisp/ob-tangle.el (org-babel-process-comment-text): (org-babel-spec-to-string): (org-babel-tangle-single-block): (org-babel-tangle-comment-links): (org-babel-tangle-jump-to-org): Silence byte-compiler.
This commit is contained in:
parent
270ed02b02
commit
65e9dcee8d
|
@ -1,4 +1,4 @@
|
||||||
;;; ob-tangle.el --- extract source code from org-mode files
|
;;; ob-tangle.el --- Extract Source Code From Org Files -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ of tangled comments."
|
||||||
:group 'org-babel
|
:group 'org-babel
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
(defcustom org-babel-process-comment-text #'org-remove-indentation
|
(defcustom org-babel-process-comment-text 'org-remove-indentation
|
||||||
"Function called to process raw Org-mode text collected to be
|
"Function called to process raw Org-mode text collected to be
|
||||||
inserted as comments in tangled source-code files. The function
|
inserted as comments in tangled source-code files. The function
|
||||||
should take a single string argument and return a string
|
should take a single string argument and return a string
|
||||||
|
@ -362,11 +362,10 @@ that the appropriate major-mode is set. SPEC has the form:
|
||||||
(comments (cdr (assq :comments info)))
|
(comments (cdr (assq :comments info)))
|
||||||
(link-p (or (string= comments "both") (string= comments "link")
|
(link-p (or (string= comments "both") (string= comments "link")
|
||||||
(string= comments "yes") (string= comments "noweb")))
|
(string= comments "yes") (string= comments "noweb")))
|
||||||
(link-data (mapcar (lambda (el)
|
(link-data `(("start-line" . ,(number-to-string start-line))
|
||||||
(cons (symbol-name el)
|
("file" . ,file)
|
||||||
(let ((le (eval el)))
|
("link" . ,link)
|
||||||
(if (stringp le) le (format "%S" le)))))
|
("source-name" . ,source-name)))
|
||||||
'(start-line file link source-name)))
|
|
||||||
(insert-comment (lambda (text)
|
(insert-comment (lambda (text)
|
||||||
(when (and comments
|
(when (and comments
|
||||||
(not (string= comments "no"))
|
(not (string= comments "no"))
|
||||||
|
@ -453,11 +452,11 @@ list to be used by `org-babel-tangle' directly."
|
||||||
(and (string-match org-bracket-link-regexp link)
|
(and (string-match org-bracket-link-regexp link)
|
||||||
(match-string 1 link))))
|
(match-string 1 link))))
|
||||||
(source-name
|
(source-name
|
||||||
(intern (or (nth 4 info)
|
(or (nth 4 info)
|
||||||
(format "%s:%d"
|
(format "%s:%d"
|
||||||
(or (ignore-errors (nth 4 (org-heading-components)))
|
(or (ignore-errors (nth 4 (org-heading-components)))
|
||||||
"No heading")
|
"No heading")
|
||||||
block-counter))))
|
block-counter)))
|
||||||
(expand-cmd
|
(expand-cmd
|
||||||
(intern (concat "org-babel-expand-body:" src-lang)))
|
(intern (concat "org-babel-expand-body:" src-lang)))
|
||||||
(assignments-cmd
|
(assignments-cmd
|
||||||
|
@ -512,17 +511,16 @@ list to be used by `org-babel-tangle' directly."
|
||||||
|
|
||||||
(defun org-babel-tangle-comment-links (&optional info)
|
(defun org-babel-tangle-comment-links (&optional info)
|
||||||
"Return a list of begin and end link comments for the code block at point."
|
"Return a list of begin and end link comments for the code block at point."
|
||||||
(let* ((start-line (org-babel-where-is-src-block-head))
|
(let ((link-data
|
||||||
(file (buffer-file-name))
|
`(("start-line" . ,(number-to-string
|
||||||
(link (org-link-escape (progn (call-interactively 'org-store-link)
|
(org-babel-where-is-src-block-head)))
|
||||||
(org-no-properties
|
("file" . ,(buffer-file-name))
|
||||||
(car (pop org-stored-links))))))
|
("link" . ,(org-link-escape
|
||||||
(source-name (nth 4 (or info (org-babel-get-src-block-info 'light))))
|
(progn
|
||||||
(link-data (mapcar (lambda (el)
|
(call-interactively #'org-store-link)
|
||||||
(cons (symbol-name el)
|
(org-no-properties (car (pop org-stored-links))))))
|
||||||
(let ((le (eval el)))
|
("source-name" .
|
||||||
(if (stringp le) le (format "%S" le)))))
|
,(nth 4 (or info (org-babel-get-src-block-info 'light)))))))
|
||||||
'(start-line file link source-name))))
|
|
||||||
(list (org-fill-template org-babel-tangle-comment-format-beg link-data)
|
(list (org-fill-template org-babel-tangle-comment-format-beg link-data)
|
||||||
(org-fill-template org-babel-tangle-comment-format-end link-data))))
|
(org-fill-template org-babel-tangle-comment-format-end link-data))))
|
||||||
|
|
||||||
|
@ -553,7 +551,7 @@ which enable the original code blocks to be found."
|
||||||
"Jump from a tangled code file to the related Org mode file."
|
"Jump from a tangled code file to the related Org mode file."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((mid (point))
|
(let ((mid (point))
|
||||||
start body-start end done
|
start body-start end
|
||||||
target-buffer target-char link path block-name body)
|
target-buffer target-char link path block-name body)
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
@ -598,7 +596,8 @@ which enable the original code blocks to be found."
|
||||||
(forward-char (- mid body-start))
|
(forward-char (- mid body-start))
|
||||||
(setq target-char (point)))
|
(setq target-char (point)))
|
||||||
(org-src-switch-to-buffer target-buffer t)
|
(org-src-switch-to-buffer target-buffer t)
|
||||||
(prog1 body (goto-char target-char))))
|
(goto-char target-char)
|
||||||
|
body))
|
||||||
|
|
||||||
(provide 'ob-tangle)
|
(provide 'ob-tangle)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue