diff options
| author | Fabián Ezequiel Gallina | 2014-12-27 13:21:17 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2014-12-27 13:21:17 -0300 |
| commit | 411c1c65313aa4e22730ba9762e073881f4e299a (patch) | |
| tree | 14833e398a5ce64db5124afafe992d47e51b70e8 /lisp | |
| parent | c3c51ec274f423cf8044cd5b9bc0bbc5bda1f6aa (diff) | |
| parent | 216c6aadf22bfb9d209b6ce9a469499fd6e1b78f (diff) | |
| download | emacs-411c1c65313aa4e22730ba9762e073881f4e299a.tar.gz emacs-411c1c65313aa4e22730ba9762e073881f4e299a.zip | |
Merge from origin/emacs-24
216c6aa * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): Use `tramp-rsh-end-of-line', it ought to be more robust.
20cfd24 Improve indexing on the chapter/section/subsection levels.
14c3739 * lisp/progmodes/js.el (js-syntax-propertize): "return" can't be divided.
ea78112 * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): Use "\n" as end-of-line delimeter for passwords, when running on MS Windows.
012479a * lisp/progmodes/sh-script.el: Don't set global indent-line-function
75e114f Fix line numbers on Python shell.
d0fd23c doc/emacs/buffers.texi (Kill Buffer): Improve indexing.
8e818d1 Keep maximized when going fullscreen.
749813e python.el: Fix electric colon behavior
936d5e5 Fix last patch.
74d3b20 Fixes: debbugs:18623
Conflicts:
doc/emacs/ChangeLog
doc/lispref/ChangeLog
doc/lispref/functions.texi
lisp/ChangeLog
src/ChangeLog
src/xterm.c
test/ChangeLog
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 45 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 8 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 261 | ||||
| -rw-r--r-- | lisp/progmodes/js.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 58 | ||||
| -rw-r--r-- | lisp/progmodes/sh-script.el | 2 |
6 files changed, 208 insertions, 168 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 81740630e2a..61e2e425ccd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,50 @@ | |||
| 1 | 2014-12-27 Michael Albinus <michael.albinus@gmx.de> | 1 | 2014-12-27 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 2 | ||
| 3 | * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): | ||
| 4 | Use `tramp-rsh-end-of-line', it ought to be more robust. | ||
| 5 | |||
| 6 | 2014-12-27 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 7 | |||
| 8 | * progmodes/js.el (js-syntax-propertize): "return" can't be divided | ||
| 9 | (bug#19397). | ||
| 10 | |||
| 11 | 2014-12-27 Michael Albinus <michael.albinus@gmx.de> | ||
| 12 | |||
| 13 | * net/tramp.el (tramp-read-passwd): Ignore errors from `auth-source-*'. | ||
| 14 | |||
| 15 | * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): Use "\n" | ||
| 16 | as end-of-line delimeter for passwords, when running on MS Windows. | ||
| 17 | |||
| 18 | 2014-12-27 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 19 | |||
| 20 | * progmodes/sh-script.el (sh-set-shell): Don't change the global value | ||
| 21 | of indent-line-function (bug#19433). | ||
| 22 | |||
| 23 | 2014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 24 | |||
| 25 | Fix line numbers on Python shell. | ||
| 26 | * progmodes/python.el (python-shell--save-temp-file): Do not | ||
| 27 | append coding cookie. | ||
| 28 | (python-shell-send-string): Generalize for | ||
| 29 | python-shell-send-region. | ||
| 30 | (python--use-fake-loc): Delete var. | ||
| 31 | (python-shell-buffer-substring): Cleanup fake-loc logic. | ||
| 32 | (python-shell-send-region): Remove fake-loc logic, simplify. | ||
| 33 | |||
| 34 | 2014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 35 | |||
| 36 | * progmodes/python.el (python-indent-post-self-insert-function): | ||
| 37 | Make colon to re-indent only for dedenters, handling | ||
| 38 | multiline-statements gracefully. | ||
| 39 | |||
| 40 | 2014-12-27 Michael Albinus <michael.albinus@gmx.de> | ||
| 41 | |||
| 42 | * net/tramp.el (tramp-handle-insert-file-contents): | ||
| 43 | Set `find-file-not-found-functions' in case of errors. (Bug#18623) | ||
| 44 | |||
| 45 | 2014-12-27 Michael Albinus <michael.albinus@gmx.de> | ||
| 46 | 2014-12-27 Michael Albinus <michael.albinus@gmx.de> | ||
| 47 | |||
| 3 | * net/tramp-sh.el (tramp-send-command-and-read): New optional | 48 | * net/tramp-sh.el (tramp-send-command-and-read): New optional |
| 4 | arg MARKER. | 49 | arg MARKER. |
| 5 | (tramp-get-remote-path): Use it. | 50 | (tramp-get-remote-path): Use it. |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 2e2e2ac3698..6fc2effbe0f 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2471,8 +2471,12 @@ The method used must be an out-of-band method." | |||
| 2471 | (mapconcat 'identity (process-command p) " ")) | 2471 | (mapconcat 'identity (process-command p) " ")) |
| 2472 | (tramp-set-connection-property p "vector" orig-vec) | 2472 | (tramp-set-connection-property p "vector" orig-vec) |
| 2473 | (tramp-compat-set-process-query-on-exit-flag p nil) | 2473 | (tramp-compat-set-process-query-on-exit-flag p nil) |
| 2474 | (tramp-process-actions | 2474 | |
| 2475 | p v nil tramp-actions-copy-out-of-band) | 2475 | ;; We must adapt `tramp-local-end-of-line' for |
| 2476 | ;; sending the password. | ||
| 2477 | (let ((tramp-local-end-of-line tramp-rsh-end-of-line)) | ||
| 2478 | (tramp-process-actions | ||
| 2479 | p v nil tramp-actions-copy-out-of-band)) | ||
| 2476 | 2480 | ||
| 2477 | ;; Check the return code. | 2481 | ;; Check the return code. |
| 2478 | (goto-char (point-max)) | 2482 | (goto-char (point-max)) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 7aba7494672..dc62ceeceb9 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3086,115 +3086,118 @@ User is always nil." | |||
| 3086 | (setq filename (expand-file-name filename)) | 3086 | (setq filename (expand-file-name filename)) |
| 3087 | (let (result local-copy remote-copy) | 3087 | (let (result local-copy remote-copy) |
| 3088 | (with-parsed-tramp-file-name filename nil | 3088 | (with-parsed-tramp-file-name filename nil |
| 3089 | (with-tramp-progress-reporter | 3089 | (unwind-protect |
| 3090 | v 3 (format "Inserting `%s'" filename) | 3090 | (if (not (file-exists-p filename)) |
| 3091 | (unwind-protect | 3091 | (tramp-error |
| 3092 | (if (not (file-exists-p filename)) | 3092 | v 'file-error "File `%s' not found on remote host" filename) |
| 3093 | (progn | 3093 | |
| 3094 | ;; We don't raise a Tramp error, because it might be | 3094 | (with-tramp-progress-reporter |
| 3095 | ;; suppressed, like in `find-file-noselect-1'. | 3095 | v 3 (format "Inserting `%s'" filename) |
| 3096 | (tramp-message | 3096 | (condition-case err |
| 3097 | v 1 "File not `%s' found on remote host" filename) | 3097 | (if (and (tramp-local-host-p v) |
| 3098 | (signal 'file-error | 3098 | (let (file-name-handler-alist) |
| 3099 | (list "File not found on remote host" filename))) | 3099 | (file-readable-p localname))) |
| 3100 | 3100 | ;; Short track: if we are on the local host, we can | |
| 3101 | (if (and (tramp-local-host-p v) | 3101 | ;; run directly. |
| 3102 | (let (file-name-handler-alist) | 3102 | (setq result |
| 3103 | (file-readable-p localname))) | 3103 | (tramp-run-real-handler |
| 3104 | ;; Short track: if we are on the local host, we can | 3104 | 'insert-file-contents |
| 3105 | ;; run directly. | 3105 | (list localname visit beg end replace))) |
| 3106 | (setq result | 3106 | |
| 3107 | (tramp-run-real-handler | 3107 | ;; When we shall insert only a part of the file, we |
| 3108 | 'insert-file-contents | 3108 | ;; copy this part. This works only for the shell file |
| 3109 | (list localname visit beg end replace))) | 3109 | ;; name handlers. |
| 3110 | 3110 | (when (and (or beg end) | |
| 3111 | ;; When we shall insert only a part of the file, we | 3111 | (tramp-get-method-parameter |
| 3112 | ;; copy this part. This works only for the shell file | 3112 | (tramp-file-name-method v) |
| 3113 | ;; name handlers. | 3113 | 'tramp-login-program)) |
| 3114 | (when (and (or beg end) | 3114 | (setq remote-copy (tramp-make-tramp-temp-file v)) |
| 3115 | (tramp-get-method-parameter | 3115 | ;; This is defined in tramp-sh.el. Let's assume |
| 3116 | (tramp-file-name-method v) 'tramp-login-program)) | 3116 | ;; this is loaded already. |
| 3117 | (setq remote-copy (tramp-make-tramp-temp-file v)) | 3117 | (tramp-compat-funcall |
| 3118 | ;; This is defined in tramp-sh.el. Let's assume | 3118 | 'tramp-send-command |
| 3119 | ;; this is loaded already. | 3119 | v |
| 3120 | (tramp-compat-funcall | 3120 | (cond |
| 3121 | 'tramp-send-command | 3121 | ((and beg end) |
| 3122 | v | 3122 | (format "dd bs=1 skip=%d if=%s count=%d of=%s" |
| 3123 | (cond | 3123 | beg (tramp-shell-quote-argument localname) |
| 3124 | ((and beg end) | 3124 | (- end beg) remote-copy)) |
| 3125 | (format "dd bs=1 skip=%d if=%s count=%d of=%s" | 3125 | (beg |
| 3126 | beg (tramp-shell-quote-argument localname) | 3126 | (format "dd bs=1 skip=%d if=%s of=%s" |
| 3127 | (- end beg) remote-copy)) | 3127 | beg (tramp-shell-quote-argument localname) |
| 3128 | (beg | 3128 | remote-copy)) |
| 3129 | (format "dd bs=1 skip=%d if=%s of=%s" | 3129 | (end |
| 3130 | beg (tramp-shell-quote-argument localname) | 3130 | (format "dd bs=1 count=%d if=%s of=%s" |
| 3131 | remote-copy)) | 3131 | end (tramp-shell-quote-argument localname) |
| 3132 | (end | 3132 | remote-copy)))) |
| 3133 | (format "dd bs=1 count=%d if=%s of=%s" | 3133 | (setq tramp-temp-buffer-file-name nil beg nil end nil)) |
| 3134 | end (tramp-shell-quote-argument localname) | 3134 | |
| 3135 | remote-copy)))) | 3135 | ;; `insert-file-contents-literally' takes care to |
| 3136 | (setq tramp-temp-buffer-file-name nil beg nil end nil)) | 3136 | ;; avoid calling jka-compr. By let-binding |
| 3137 | 3137 | ;; `inhibit-file-name-operation', we propagate that | |
| 3138 | ;; `insert-file-contents-literally' takes care to | 3138 | ;; care to the `file-local-copy' operation. |
| 3139 | ;; avoid calling jka-compr. By let-binding | 3139 | (setq local-copy |
| 3140 | ;; `inhibit-file-name-operation', we propagate that | 3140 | (let ((inhibit-file-name-operation |
| 3141 | ;; care to the `file-local-copy' operation. | 3141 | (when (eq inhibit-file-name-operation |
| 3142 | (setq local-copy | 3142 | 'insert-file-contents) |
| 3143 | (let ((inhibit-file-name-operation | 3143 | 'file-local-copy))) |
| 3144 | (when (eq inhibit-file-name-operation | 3144 | (cond |
| 3145 | 'insert-file-contents) | 3145 | ((stringp remote-copy) |
| 3146 | 'file-local-copy))) | 3146 | (file-local-copy |
| 3147 | (cond | 3147 | (tramp-make-tramp-file-name |
| 3148 | ((stringp remote-copy) | 3148 | method user host remote-copy))) |
| 3149 | (file-local-copy | 3149 | ((stringp tramp-temp-buffer-file-name) |
| 3150 | (tramp-make-tramp-file-name | 3150 | (copy-file |
| 3151 | method user host remote-copy))) | 3151 | filename tramp-temp-buffer-file-name 'ok) |
| 3152 | ((stringp tramp-temp-buffer-file-name) | 3152 | tramp-temp-buffer-file-name) |
| 3153 | (copy-file filename tramp-temp-buffer-file-name 'ok) | 3153 | (t (file-local-copy filename))))) |
| 3154 | tramp-temp-buffer-file-name) | 3154 | |
| 3155 | (t (file-local-copy filename))))) | 3155 | ;; When the file is not readable for the owner, it |
| 3156 | 3156 | ;; cannot be inserted, even if it is readable for the | |
| 3157 | ;; When the file is not readable for the owner, it | 3157 | ;; group or for everybody. |
| 3158 | ;; cannot be inserted, even if it is readable for the | 3158 | (set-file-modes |
| 3159 | ;; group or for everybody. | 3159 | local-copy (tramp-compat-octal-to-decimal "0600")) |
| 3160 | (set-file-modes | 3160 | |
| 3161 | local-copy (tramp-compat-octal-to-decimal "0600")) | 3161 | (when (and (null remote-copy) |
| 3162 | 3162 | (tramp-get-method-parameter | |
| 3163 | (when (and (null remote-copy) | 3163 | method 'tramp-copy-keep-tmpfile)) |
| 3164 | (tramp-get-method-parameter | 3164 | ;; We keep the local file for performance reasons, |
| 3165 | method 'tramp-copy-keep-tmpfile)) | 3165 | ;; useful for "rsync". |
| 3166 | ;; We keep the local file for performance reasons, | 3166 | (setq tramp-temp-buffer-file-name local-copy)) |
| 3167 | ;; useful for "rsync". | 3167 | |
| 3168 | (setq tramp-temp-buffer-file-name local-copy)) | 3168 | ;; We must ensure that `file-coding-system-alist' |
| 3169 | 3169 | ;; matches `local-copy'. We must also use `visit', | |
| 3170 | ;; We must ensure that `file-coding-system-alist' | 3170 | ;; otherwise there might be an error in the |
| 3171 | ;; matches `local-copy'. We must also use `visit', | 3171 | ;; `revert-buffer' function under XEmacs. |
| 3172 | ;; otherwise there might be an error in the | 3172 | (let ((file-coding-system-alist |
| 3173 | ;; `revert-buffer' function under XEmacs. | 3173 | (tramp-find-file-name-coding-system-alist |
| 3174 | (let ((file-coding-system-alist | 3174 | filename local-copy))) |
| 3175 | (tramp-find-file-name-coding-system-alist | 3175 | (setq result |
| 3176 | filename local-copy))) | 3176 | (insert-file-contents |
| 3177 | (setq result | 3177 | local-copy visit beg end replace)))) |
| 3178 | (insert-file-contents | 3178 | (error |
| 3179 | local-copy visit beg end replace))))) | 3179 | (add-hook 'find-file-not-found-functions |
| 3180 | 3180 | `(lambda () (signal ',(car err) ',(cdr err))) | |
| 3181 | ;; Save exit. | 3181 | nil t) |
| 3182 | (progn | 3182 | (signal (car err) (cdr err)))))) |
| 3183 | (when visit | 3183 | |
| 3184 | (setq buffer-file-name filename) | 3184 | ;; Save exit. |
| 3185 | (setq buffer-read-only (not (file-writable-p filename))) | 3185 | (progn |
| 3186 | (set-visited-file-modtime) | 3186 | (when visit |
| 3187 | (set-buffer-modified-p nil)) | 3187 | (setq buffer-file-name filename) |
| 3188 | (when (and (stringp local-copy) | 3188 | (setq buffer-read-only (not (file-writable-p filename))) |
| 3189 | (or remote-copy (null tramp-temp-buffer-file-name))) | 3189 | (set-visited-file-modtime) |
| 3190 | (delete-file local-copy)) | 3190 | (set-buffer-modified-p nil)) |
| 3191 | (when (stringp remote-copy) | 3191 | (when (and (stringp local-copy) |
| 3192 | (delete-file | 3192 | (or remote-copy (null tramp-temp-buffer-file-name))) |
| 3193 | (tramp-make-tramp-file-name method user host remote-copy))))))) | 3193 | (delete-file local-copy)) |
| 3194 | 3194 | (when (stringp remote-copy) | |
| 3195 | ;; Result. | 3195 | (delete-file |
| 3196 | (list (expand-file-name filename) | 3196 | (tramp-make-tramp-file-name method user host remote-copy))))) |
| 3197 | (cadr result)))) | 3197 | |
| 3198 | ;; Result. | ||
| 3199 | (list (expand-file-name filename) | ||
| 3200 | (cadr result))))) | ||
| 3198 | 3201 | ||
| 3199 | (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) | 3202 | (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) |
| 3200 | "Like `load' for Tramp files." | 3203 | "Like `load' for Tramp files." |
| @@ -4188,25 +4191,27 @@ Invokes `password-read' if available, `read-passwd' else." | |||
| 4188 | ;; it's bound. `auth-source-user-or-password' is an | 4191 | ;; it's bound. `auth-source-user-or-password' is an |
| 4189 | ;; obsoleted function, it has been replaced by | 4192 | ;; obsoleted function, it has been replaced by |
| 4190 | ;; `auth-source-search'. | 4193 | ;; `auth-source-search'. |
| 4191 | (and (boundp 'auth-sources) | 4194 | (ignore-errors |
| 4192 | (tramp-get-connection-property | 4195 | (and (boundp 'auth-sources) |
| 4193 | v "first-password-request" nil) | 4196 | (tramp-get-connection-property |
| 4194 | ;; Try with Tramp's current method. | 4197 | v "first-password-request" nil) |
| 4195 | (if (fboundp 'auth-source-search) | 4198 | ;; Try with Tramp's current method. |
| 4196 | (setq auth-info | 4199 | (if (fboundp 'auth-source-search) |
| 4197 | (tramp-compat-funcall | 4200 | (setq auth-info |
| 4198 | 'auth-source-search | 4201 | (tramp-compat-funcall |
| 4199 | :max 1 | 4202 | 'auth-source-search |
| 4200 | :user (or tramp-current-user t) | 4203 | :max 1 |
| 4201 | :host tramp-current-host | 4204 | :user (or tramp-current-user t) |
| 4202 | :port tramp-current-method) | 4205 | :host tramp-current-host |
| 4203 | auth-passwd (plist-get (nth 0 auth-info) :secret) | 4206 | :port tramp-current-method) |
| 4204 | auth-passwd (if (functionp auth-passwd) | 4207 | auth-passwd (plist-get |
| 4205 | (funcall auth-passwd) | 4208 | (nth 0 auth-info) :secret) |
| 4206 | auth-passwd)) | 4209 | auth-passwd (if (functionp auth-passwd) |
| 4207 | (tramp-compat-funcall | 4210 | (funcall auth-passwd) |
| 4208 | 'auth-source-user-or-password | 4211 | auth-passwd)) |
| 4209 | "password" tramp-current-host tramp-current-method))) | 4212 | (tramp-compat-funcall |
| 4213 | 'auth-source-user-or-password | ||
| 4214 | "password" tramp-current-host tramp-current-method)))) | ||
| 4210 | ;; Try the password cache. | 4215 | ;; Try the password cache. |
| 4211 | (when (functionp 'password-read) | 4216 | (when (functionp 'password-read) |
| 4212 | (let ((password | 4217 | (let ((password |
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45074d338d3..f6a9440610e 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -1673,7 +1673,7 @@ This performs fontification according to `js--class-styles'." | |||
| 1673 | ;; We can probably just add +, -, !, <, >, %, ^, ~, |, &, ?, : at which | 1673 | ;; We can probably just add +, -, !, <, >, %, ^, ~, |, &, ?, : at which |
| 1674 | ;; point I think only * and / would be missing which could also be added, | 1674 | ;; point I think only * and / would be missing which could also be added, |
| 1675 | ;; but need care to avoid affecting the // and */ comment markers. | 1675 | ;; but need care to avoid affecting the // and */ comment markers. |
| 1676 | ("\\(?:^\\|[=([{,:;]\\)\\(?:[ \t]\\)*\\(/\\)[^/*]" | 1676 | ("\\(?:^\\|[=([{,:;]\\|\\_<return\\_>\\)\\(?:[ \t]\\)*\\(/\\)[^/*]" |
| 1677 | (1 (ignore | 1677 | (1 (ignore |
| 1678 | (forward-char -1) | 1678 | (forward-char -1) |
| 1679 | (when (or (not (memq (char-after (match-beginning 0)) '(?\s ?\t))) | 1679 | (when (or (not (memq (char-after (match-beginning 0)) '(?\s ?\t))) |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index bd8c734e0b9..b1c6b01c4dc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1206,12 +1206,18 @@ the line will be re-indented automatically if needed." | |||
| 1206 | (eolp) | 1206 | (eolp) |
| 1207 | ;; Avoid re-indenting on extra colon | 1207 | ;; Avoid re-indenting on extra colon |
| 1208 | (not (equal ?: (char-before (1- (point))))) | 1208 | (not (equal ?: (char-before (1- (point))))) |
| 1209 | (not (python-syntax-comment-or-string-p)) | 1209 | (not (python-syntax-comment-or-string-p))) |
| 1210 | ;; Never re-indent at beginning of defun | 1210 | ;; Just re-indent dedenters |
| 1211 | (not (save-excursion | 1211 | (let ((dedenter-pos (python-info-dedenter-statement-p)) |
| 1212 | (python-nav-beginning-of-statement) | 1212 | (current-pos (point))) |
| 1213 | (python-info-looking-at-beginning-of-defun)))) | 1213 | (when dedenter-pos |
| 1214 | (python-indent-line))))) | 1214 | (save-excursion |
| 1215 | (goto-char dedenter-pos) | ||
| 1216 | (python-indent-line) | ||
| 1217 | (unless (= (line-number-at-pos dedenter-pos) | ||
| 1218 | (line-number-at-pos current-pos)) | ||
| 1219 | ;; Reindent region if this is a multiline statement | ||
| 1220 | (python-indent-region dedenter-pos current-pos))))))))) | ||
| 1215 | 1221 | ||
| 1216 | 1222 | ||
| 1217 | ;;; Navigation | 1223 | ;;; Navigation |
| @@ -2608,9 +2614,12 @@ there for compatibility with CEDET.") | |||
| 2608 | (concat (file-remote-p default-directory) "/tmp") | 2614 | (concat (file-remote-p default-directory) "/tmp") |
| 2609 | temporary-file-directory)) | 2615 | temporary-file-directory)) |
| 2610 | (temp-file-name (make-temp-file "py")) | 2616 | (temp-file-name (make-temp-file "py")) |
| 2617 | ;; XXX: Python's built-in compile function accepts utf-8 as | ||
| 2618 | ;; input so there's no need to enforce a coding cookie. In | ||
| 2619 | ;; the future making `coding-system-for-write' match the | ||
| 2620 | ;; current buffer's coding may be a good idea. | ||
| 2611 | (coding-system-for-write 'utf-8)) | 2621 | (coding-system-for-write 'utf-8)) |
| 2612 | (with-temp-file temp-file-name | 2622 | (with-temp-file temp-file-name |
| 2613 | (insert "# -*- coding: utf-8 -*-\n") ;Not needed for Python-3. | ||
| 2614 | (insert string) | 2623 | (insert string) |
| 2615 | (delete-trailing-whitespace)) | 2624 | (delete-trailing-whitespace)) |
| 2616 | temp-file-name)) | 2625 | temp-file-name)) |
| @@ -2620,8 +2629,9 @@ there for compatibility with CEDET.") | |||
| 2620 | (interactive "sPython command: ") | 2629 | (interactive "sPython command: ") |
| 2621 | (let ((process (or process (python-shell-get-or-create-process)))) | 2630 | (let ((process (or process (python-shell-get-or-create-process)))) |
| 2622 | (if (string-match ".\n+." string) ;Multiline. | 2631 | (if (string-match ".\n+." string) ;Multiline. |
| 2623 | (let* ((temp-file-name (python-shell--save-temp-file string))) | 2632 | (let* ((temp-file-name (python-shell--save-temp-file string)) |
| 2624 | (python-shell-send-file temp-file-name process temp-file-name t)) | 2633 | (file-name (or (buffer-file-name) temp-file-name))) |
| 2634 | (python-shell-send-file file-name process temp-file-name t)) | ||
| 2625 | (comint-send-string process string) | 2635 | (comint-send-string process string) |
| 2626 | (when (or (not (string-match "\n\\'" string)) | 2636 | (when (or (not (string-match "\n\\'" string)) |
| 2627 | (string-match "\n[ \t].*\n?\\'" string)) | 2637 | (string-match "\n[ \t].*\n?\\'" string)) |
| @@ -2697,12 +2707,6 @@ Returns the output. See `python-shell-send-string-no-output'." | |||
| 2697 | (define-obsolete-function-alias | 2707 | (define-obsolete-function-alias |
| 2698 | 'python-send-string 'python-shell-internal-send-string "24.3") | 2708 | 'python-send-string 'python-shell-internal-send-string "24.3") |
| 2699 | 2709 | ||
| 2700 | (defvar python--use-fake-loc nil | ||
| 2701 | "If non-nil, use `compilation-fake-loc' to trace errors back to the buffer. | ||
| 2702 | If nil, regions of text are prepended by the corresponding number of empty | ||
| 2703 | lines and Python is told to output error messages referring to the whole | ||
| 2704 | source file.") | ||
| 2705 | |||
| 2706 | (defun python-shell-buffer-substring (start end &optional nomain) | 2710 | (defun python-shell-buffer-substring (start end &optional nomain) |
| 2707 | "Send buffer substring from START to END formatted for shell. | 2711 | "Send buffer substring from START to END formatted for shell. |
| 2708 | This is a wrapper over `buffer-substring' that takes care of | 2712 | This is a wrapper over `buffer-substring' that takes care of |
| @@ -2715,8 +2719,7 @@ the python shell: | |||
| 2715 | 3. Wraps indented regions under an \"if True:\" block so the | 2719 | 3. Wraps indented regions under an \"if True:\" block so the |
| 2716 | interpreter evaluates them correctly." | 2720 | interpreter evaluates them correctly." |
| 2717 | (let ((substring (buffer-substring-no-properties start end)) | 2721 | (let ((substring (buffer-substring-no-properties start end)) |
| 2718 | (fillstr (unless python--use-fake-loc | 2722 | (fillstr (make-string (1- (line-number-at-pos start)) ?\n)) |
| 2719 | (make-string (1- (line-number-at-pos start)) ?\n))) | ||
| 2720 | (toplevel-block-p (save-excursion | 2723 | (toplevel-block-p (save-excursion |
| 2721 | (goto-char start) | 2724 | (goto-char start) |
| 2722 | (or (zerop (line-number-at-pos start)) | 2725 | (or (zerop (line-number-at-pos start)) |
| @@ -2728,11 +2731,6 @@ the python shell: | |||
| 2728 | (if fillstr (insert fillstr)) | 2731 | (if fillstr (insert fillstr)) |
| 2729 | (insert substring) | 2732 | (insert substring) |
| 2730 | (goto-char (point-min)) | 2733 | (goto-char (point-min)) |
| 2731 | (unless python--use-fake-loc | ||
| 2732 | ;; python-shell--save-temp-file adds an extra coding line, which would | ||
| 2733 | ;; throw off the line-counts, so let's try to compensate here. | ||
| 2734 | (if (looking-at "[ \t]*[#\n]") | ||
| 2735 | (delete-region (point) (line-beginning-position 2)))) | ||
| 2736 | (when (not toplevel-block-p) | 2734 | (when (not toplevel-block-p) |
| 2737 | (insert "if True:") | 2735 | (insert "if True:") |
| 2738 | (delete-region (point) (line-end-position))) | 2736 | (delete-region (point) (line-end-position))) |
| @@ -2756,26 +2754,14 @@ the python shell: | |||
| 2756 | (line-number-at-pos if-name-main-start)) ?\n))))) | 2754 | (line-number-at-pos if-name-main-start)) ?\n))))) |
| 2757 | (buffer-substring-no-properties (point-min) (point-max))))) | 2755 | (buffer-substring-no-properties (point-min) (point-max))))) |
| 2758 | 2756 | ||
| 2759 | (declare-function compilation-fake-loc "compile" | ||
| 2760 | (marker file &optional line col)) | ||
| 2761 | |||
| 2762 | (defun python-shell-send-region (start end &optional nomain) | 2757 | (defun python-shell-send-region (start end &optional nomain) |
| 2763 | "Send the region delimited by START and END to inferior Python process." | 2758 | "Send the region delimited by START and END to inferior Python process." |
| 2764 | (interactive "r") | 2759 | (interactive "r") |
| 2765 | (let* ((python--use-fake-loc | 2760 | (let* ((string (python-shell-buffer-substring start end nomain)) |
| 2766 | (or python--use-fake-loc (not buffer-file-name))) | ||
| 2767 | (string (python-shell-buffer-substring start end nomain)) | ||
| 2768 | (process (python-shell-get-or-create-process)) | 2761 | (process (python-shell-get-or-create-process)) |
| 2769 | (_ (string-match "\\`\n*\\(.*\\)" string))) | 2762 | (_ (string-match "\\`\n*\\(.*\\)" string))) |
| 2770 | (message "Sent: %s..." (match-string 1 string)) | 2763 | (message "Sent: %s..." (match-string 1 string)) |
| 2771 | (let* ((temp-file-name (python-shell--save-temp-file string)) | 2764 | (python-shell-send-string string process))) |
| 2772 | (file-name (or (buffer-file-name) temp-file-name))) | ||
| 2773 | (python-shell-send-file file-name process temp-file-name t) | ||
| 2774 | (unless python--use-fake-loc | ||
| 2775 | (with-current-buffer (process-buffer process) | ||
| 2776 | (compilation-fake-loc (copy-marker start) temp-file-name | ||
| 2777 | 2)) ;; Not 1, because of the added coding line. | ||
| 2778 | )))) | ||
| 2779 | 2765 | ||
| 2780 | (defun python-shell-send-buffer (&optional arg) | 2766 | (defun python-shell-send-buffer (&optional arg) |
| 2781 | "Send the entire buffer to inferior Python process. | 2767 | "Send the entire buffer to inferior Python process. |
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 524749d6266..904e9dfc289 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el | |||
| @@ -2374,7 +2374,7 @@ Calls the value of `sh-set-shell-hook' if set." | |||
| 2374 | (sh-make-vars-local)) | 2374 | (sh-make-vars-local)) |
| 2375 | (message "Indentation setup for shell type %s" sh-shell)) | 2375 | (message "Indentation setup for shell type %s" sh-shell)) |
| 2376 | (message "No indentation for this shell type.") | 2376 | (message "No indentation for this shell type.") |
| 2377 | (setq indent-line-function 'sh-basic-indent-line)) | 2377 | (setq-local indent-line-function 'sh-basic-indent-line)) |
| 2378 | (when font-lock-mode | 2378 | (when font-lock-mode |
| 2379 | (setq font-lock-set-defaults nil) | 2379 | (setq font-lock-set-defaults nil) |
| 2380 | (font-lock-set-defaults) | 2380 | (font-lock-set-defaults) |