aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-05-17 00:03:24 -0300
committerFabián Ezequiel Gallina2012-05-17 00:03:24 -0300
commitd2190c5795c2848f144ab034b4b397d51c89f5c4 (patch)
tree44549bc7fc80bfcaddf1860cac890f8a5b3cb9b9 /lisp/progmodes/python.el
parent307bd2e8c72c33811fa6bf32a23b08fda84b282e (diff)
downloademacs-d2190c5795c2848f144ab034b4b397d51c89f5c4.tar.gz
emacs-d2190c5795c2848f144ab034b4b397d51c89f5c4.zip
New function python-clone-local-variables
Copied from org.el: it allows the `python-shell-make-comint' to be simplified. It copies all local variables from a buffer to the current.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el56
1 files changed, 16 insertions, 40 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 3d25f0b46c8..7ded2c897a8 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1266,48 +1266,10 @@ non-nil the buffer is shown."
1266 (let* ((cmdlist (split-string-and-unquote cmd)) 1266 (let* ((cmdlist (split-string-and-unquote cmd))
1267 (buffer (apply 'make-comint proc-name (car cmdlist) nil 1267 (buffer (apply 'make-comint proc-name (car cmdlist) nil
1268 (cdr cmdlist))) 1268 (cdr cmdlist)))
1269 (python-shell-interpreter-1 python-shell-interpreter) 1269 (current-buffer (current-buffer)))
1270 (python-shell-interpreter-args-1 python-shell-interpreter-args)
1271 (python-shell-prompt-regexp-1 python-shell-prompt-regexp)
1272 (python-shell-prompt-output-regexp-1
1273 python-shell-prompt-output-regexp)
1274 (python-shell-prompt-block-regexp-1
1275 python-shell-prompt-block-regexp)
1276 (python-shell-completion-setup-code-1
1277 python-shell-completion-setup-code)
1278 (python-shell-completion-string-code-1
1279 python-shell-completion-string-code)
1280 (python-eldoc-setup-code-1 python-eldoc-setup-code)
1281 (python-eldoc-string-code-1 python-eldoc-string-code)
1282 (python-ffap-setup-code-1 python-ffap-setup-code)
1283 (python-ffap-string-code-1 python-ffap-string-code)
1284 (python-shell-setup-codes-1 python-shell-setup-codes))
1285 (with-current-buffer buffer 1270 (with-current-buffer buffer
1286 (inferior-python-mode) 1271 (inferior-python-mode)
1287 (set (make-local-variable 'python-shell-interpreter) 1272 (python-clone-local-variables current-buffer))))
1288 python-shell-interpreter-1)
1289 (set (make-local-variable 'python-shell-interpreter-args)
1290 python-shell-interpreter-args-1)
1291 (set (make-local-variable 'python-shell-prompt-regexp)
1292 python-shell-prompt-regexp-1)
1293 (set (make-local-variable 'python-shell-prompt-output-regexp)
1294 python-shell-prompt-output-regexp-1)
1295 (set (make-local-variable 'python-shell-prompt-block-regexp)
1296 python-shell-prompt-block-regexp-1)
1297 (set (make-local-variable 'python-shell-completion-setup-code)
1298 python-shell-completion-setup-code-1)
1299 (set (make-local-variable 'python-shell-completion-string-code)
1300 python-shell-completion-string-code-1)
1301 (set (make-local-variable 'python-eldoc-setup-code)
1302 python-eldoc-setup-code-1)
1303 (set (make-local-variable 'python-eldoc-string-code)
1304 python-eldoc-string-code-1)
1305 (set (make-local-variable 'python-ffap-setup-code)
1306 python-ffap-setup-code-1)
1307 (set (make-local-variable 'python-ffap-string-code)
1308 python-ffap-string-code-1)
1309 (set (make-local-variable 'python-shell-setup-codes)
1310 python-shell-setup-codes-1))))
1311 (when pop 1273 (when pop
1312 (pop-to-buffer proc-buffer-name))))) 1274 (pop-to-buffer proc-buffer-name)))))
1313 1275
@@ -2480,6 +2442,20 @@ Return the index of the matching item, or nil if not found."
2480 (when member-result 2442 (when member-result
2481 (- (length seq) (length member-result))))) 2443 (- (length seq) (length member-result)))))
2482 2444
2445;; Stolen from org-mode
2446(defun python-clone-local-variables (from-buffer &optional regexp)
2447 "Clone local variables from FROM-BUFFER.
2448Optional argument REGEXP selects variables to clone and defaults
2449to \"^python-\"."
2450 (mapc
2451 (lambda (pair)
2452 (and (symbolp (car pair))
2453 (string-match (or regexp "^python-")
2454 (symbol-name (car pair)))
2455 (set (make-local-variable (car pair))
2456 (cdr pair))))
2457 (buffer-local-variables from-buffer)))
2458
2483 2459
2484;;;###autoload 2460;;;###autoload
2485(define-derived-mode python-mode fundamental-mode "Python" 2461(define-derived-mode python-mode fundamental-mode "Python"