Skip to content

Commit

Permalink
Backport commit 1203e8a from Emacs
Browse files Browse the repository at this point in the history
* lisp/ob-core.el (org-babel-check-confirm-evaluate)
(org-babel-map-src-blocks): Don't emit warnings if added vars are not used.
(*this*): Declare as dyn-bound.
(org-babel-expand-src-block, org-babel-load-in-session)
(org-babel-switch-to-session-with-code, org-babel-get-rownames):
Mark unused args.
(org-babel-combine-header-arg-lists): Remove unused var `args'.

* lisp/org-src.el (org-inhibit-startup):
Declare as dyn-bound.

lisp/org: Fix some compiler warnings
1203e8aecb7f49621af52cc13bc0e4427545dd4f
Stefan Monnier
Mon Jan 25 10:11:31 2016 -0500
  • Loading branch information
monnier authored and kyleam committed Jan 26, 2016
1 parent 7b9f2fb commit 1218985
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
29 changes: 20 additions & 9 deletions lisp/ob-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ name of the code block."
org-confirm-babel-evaluate)))
(code-block (if ,info (format " %s " ,lang) " "))
(block-name (if ,name (format " (%s) " ,name) " ")))
;; Silence byte-compiler is `body' doesn't use those vars.
(ignore noeval query)
,@body)))

(defsubst org-babel-check-evaluate (info)
Expand Down Expand Up @@ -613,6 +615,8 @@ multiple blocks are being executed (e.g., in chained execution
through use of the :var header argument) this marker points to
the outer-most code block.")

(defvar *this*)

;;;###autoload
(defun org-babel-execute-src-block (&optional arg info params)
"Execute the current source code block.
Expand Down Expand Up @@ -660,7 +664,8 @@ block."
(skip-chars-forward " \t")
(let ((result (org-babel-read-result)))
(message (replace-regexp-in-string
"%" "%%" (format "%S" result))) result)))
"%" "%%" (format "%S" result)))
result)))
((org-babel-confirm-evaluate
(let ((i info)) (setf (nth 2 i) merged-params) i))
(let* ((lang (nth 0 info))
Expand Down Expand Up @@ -756,7 +761,7 @@ org-babel-expand-body:lang function."
"\n")))

;;;###autoload
(defun org-babel-expand-src-block (&optional arg info params)
(defun org-babel-expand-src-block (&optional _arg info params)
"Expand the current source code block.
Expand according to the source code block's header
arguments and pop open the results in a preview buffer."
Expand Down Expand Up @@ -809,8 +814,7 @@ arguments and pop open the results in a preview buffer."
(let ((results (copy-sequence original)))
(dolist (new-list others)
(dolist (arg-pair new-list)
(let ((header (car arg-pair))
(args (cdr arg-pair)))
(let ((header (car arg-pair)))
(setq results
(cons arg-pair (org-remove-if
(lambda (pair) (equal header (car pair)))
Expand Down Expand Up @@ -903,7 +907,7 @@ arguments and pop open the results in a preview buffer."
(add-hook 'org-tab-first-hook 'org-babel-header-arg-expand)

;;;###autoload
(defun org-babel-load-in-session (&optional arg info)
(defun org-babel-load-in-session (&optional _arg info)
"Load the body of the current source-code block.
Evaluate the header arguments for the source block before
entering the session. After loading the body this pops open the
Expand Down Expand Up @@ -972,7 +976,7 @@ with a prefix argument then this is passed on to
(defvar org-src-window-setup)

;;;###autoload
(defun org-babel-switch-to-session-with-code (&optional arg info)
(defun org-babel-switch-to-session-with-code (&optional arg _info)
"Switch to code buffer and display session."
(interactive "P")
(let ((swap-windows
Expand Down Expand Up @@ -1098,7 +1102,13 @@ end-body --------- point at the end of the body"
(body (match-string 5))
(beg-body (match-beginning 5))
(end-body (match-end 5)))
,@body
;; Silence byte-compiler in case `body' doesn't use all
;; those variables.
(ignore full-block beg-block end-block lang
beg-lang end-lang switches beg-switches
end-switches header-args beg-header-args
end-header-args body beg-body end-body)
,@body
(goto-char end-block)))))
(unless visited-p (kill-buffer to-be-removed))
(goto-char point))))
Expand Down Expand Up @@ -1625,7 +1635,7 @@ Note: this function removes any hlines in TABLE."
(rownames (funcall (lambda ()
(let ((tp table))
(mapcar
(lambda (row)
(lambda (_row)
(prog1
(pop (car tp))
(setq tp (cdr tp))))
Expand Down Expand Up @@ -1803,7 +1813,8 @@ buffer or nil if no such result exists."
(catch 'is-a-code-block
(when (re-search-forward
(concat org-babel-result-regexp
"[ \t]" (regexp-quote name) "[ \t]*[\n\f\v\r]") nil t)
"[ \t]" (regexp-quote name) "[ \t]*[\n\f\v\r]")
nil t)
(when (and (string= "name" (downcase (match-string 1)))
(or (beginning-of-line 1)
(looking-at org-babel-src-block-regexp)
Expand Down
1 change: 1 addition & 0 deletions lisp/org-src.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
(declare-function org-trim "org" (s))

(defvar org-element-all-elements)
(defvar org-inhibit-startup)

(defcustom org-edit-src-turn-on-auto-save nil
"Non-nil means turn `auto-save-mode' on when editing a source block.
Expand Down

0 comments on commit 1218985

Please sign in to comment.