------------------------------------------------------------ revno: 115209 committer: Bozhidar Batsov branch nick: master timestamp: Sun 2013-11-24 11:31:51 +0200 message: * lisp/emacs-lisp/helpers.el: Add some string helpers. (string-trim-left): Removes leading whitespace. (string-trim-right): Removes trailing whitespace. (string-trim): Removes leading and trailing whitespace. diff: === modified file 'etc/NEWS' --- etc/NEWS 2013-11-24 08:49:44 +0000 +++ etc/NEWS 2013-11-24 09:31:51 +0000 @@ -769,6 +769,9 @@ ** New library helpers.el for misc helper functions *** `hash-table-keys' *** `hash-table-values' +*** `string-trim-left' +*** `string-trim-right' +*** `string-trim' ** Obsoleted functions: *** `log10' === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-11-24 08:49:44 +0000 +++ lisp/ChangeLog 2013-11-24 09:31:51 +0000 @@ -1,5 +1,10 @@ 2013-11-24 Bozhidar Batsov + * emacs-lisp/helpers.el: Add some string helpers. + (string-trim-left): Removes leading whitespace. + (string-trim-right): Removes trailing whitespace. + (string-trim): Removes leading and trailing whitespace. + * subr.el (string-suffix-p): New function. 2013-11-23 Glenn Morris === modified file 'lisp/emacs-lisp/helpers.el' --- lisp/emacs-lisp/helpers.el 2013-11-04 19:25:09 +0000 +++ lisp/emacs-lisp/helpers.el 2013-11-24 09:31:51 +0000 @@ -37,6 +37,22 @@ (maphash (lambda (_k v) (push v values)) hash-table) values)) +(defsubst string-trim-left (string) + "Remove leading whitespace from STRING." + (if (string-match "\\`[ \t\n\r]+" string) + (replace-match "" t t string) + string)) + +(defsubst string-trim-right (string) + "Remove trailing whitespace from STRING." + (if (string-match "[ \t\n\r]+\\'" string) + (replace-match "" t t string) + string)) + +(defsubst string-trim (string) + "Remove leading and trailing whitespace from STRING." + (string-trim-left (string-trim-right string))) + (provide 'helpers) ;;; helpers.el ends here ------------------------------------------------------------ revno: 115208 committer: Bozhidar Batsov branch nick: master timestamp: Sun 2013-11-24 10:49:44 +0200 message: * lisp/subr.el (string-suffix-p): New function. diff: === modified file 'etc/NEWS' --- etc/NEWS 2013-11-23 19:07:34 +0000 +++ etc/NEWS 2013-11-24 08:49:44 +0000 @@ -790,6 +790,8 @@ The value, if non-nil, is a regexp that specifies what to trim from the start and end of each substring. +** New function `string-suffix-p'. + ** `get-upcase-table' is obsoleted by the new `case-table-get-table'. ** Support for filesystem notifications. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-11-23 19:39:50 +0000 +++ lisp/ChangeLog 2013-11-24 08:49:44 +0000 @@ -1,3 +1,7 @@ +2013-11-24 Bozhidar Batsov + + * subr.el (string-suffix-p): New function. + 2013-11-23 Glenn Morris * progmodes/python.el (python-shell-send-file): === modified file 'lisp/subr.el' --- lisp/subr.el 2013-11-15 10:02:13 +0000 +++ lisp/subr.el 2013-11-24 08:49:44 +0000 @@ -3635,6 +3635,15 @@ (eq t (compare-strings str1 nil nil str2 0 (length str1) ignore-case))) +(defun string-suffix-p (suffix string &optional ignore-case) + "Return non-nil if SUFFIX is a suffix of STRING. +If IGNORE-CASE is non-nil, the comparison is done without paying +attention to case differences." + (let ((start-pos (- (length string) (length suffix)))) + (and (>= start-pos 0) + (eq t (compare-strings suffix nil nil + string start-pos nil ignore-case))))) + (defun bidi-string-mark-left-to-right (str) "Return a string that can be safely inserted in left-to-right text. ------------------------------------------------------------ revno: 115207 committer: Glenn Morris branch nick: trunk timestamp: Sat 2013-11-23 12:46:43 -0800 message: Stop some python tests leaving temp-files behind * test/automated/python-tests.el (python-shell-make-comint-1) (python-shell-make-comint-2, python-shell-get-process-1): Suppress creation of some temp-files. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-11-23 20:42:38 +0000 +++ test/ChangeLog 2013-11-23 20:46:43 +0000 @@ -1,5 +1,9 @@ 2013-11-23 Glenn Morris + * automated/python-tests.el (python-shell-make-comint-1) + (python-shell-make-comint-2, python-shell-get-process-1): + Suppress creation of some temp-files. + * automated/python-tests.el (python-shell-parse-command-1) (python-shell-make-comint-1, python-shell-make-comint-2) (python-shell-get-process-1) === modified file 'test/automated/python-tests.el' --- test/automated/python-tests.el 2013-11-23 20:42:38 +0000 +++ test/automated/python-tests.el 2013-11-23 20:46:43 +0000 @@ -1521,7 +1521,11 @@ (ert-deftest python-shell-make-comint-1 () "Check comint creation for global shell buffer." (skip-unless (executable-find python-tests-shell-interpreter)) - (let* ((python-shell-interpreter + ;; The interpreter can get killed too quickly to allow it to clean + ;; up the tempfiles that the default python-shell-setup-codes create, + ;; so it leaves tempfiles behind, which is a minor irritation. + (let* ((python-shell-setup-codes nil) + (python-shell-interpreter (executable-find python-tests-shell-interpreter)) (proc-name (python-shell-get-process-name nil)) (shell-buffer @@ -1541,7 +1545,8 @@ (ert-deftest python-shell-make-comint-2 () "Check comint creation for internal shell buffer." (skip-unless (executable-find python-tests-shell-interpreter)) - (let* ((python-shell-interpreter + (let* ((python-shell-setup-codes nil) + (python-shell-interpreter (executable-find python-tests-shell-interpreter)) (proc-name (python-shell-internal-get-process-name)) (shell-buffer @@ -1563,7 +1568,8 @@ (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-file "" - (let* ((python-shell-interpreter + (let* ((python-shell-setup-codes nil) + (python-shell-interpreter (executable-find python-tests-shell-interpreter)) (global-proc-name (python-shell-get-process-name nil)) (dedicated-proc-name (python-shell-get-process-name t)) ------------------------------------------------------------ revno: 115206 committer: Glenn Morris branch nick: trunk timestamp: Sat 2013-11-23 12:42:38 -0800 message: Use skip-unless in some python tests * test/automated/python-tests.el (python-shell-parse-command-1) (python-shell-make-comint-1, python-shell-make-comint-2) (python-shell-get-process-1) (python-shell-internal-get-or-create-process-1): Skip rather than fail if prereqs not found. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-11-23 01:55:16 +0000 +++ test/ChangeLog 2013-11-23 20:42:38 +0000 @@ -1,5 +1,11 @@ 2013-11-23 Glenn Morris + * automated/python-tests.el (python-shell-parse-command-1) + (python-shell-make-comint-1, python-shell-make-comint-2) + (python-shell-get-process-1) + (python-shell-internal-get-or-create-process-1): + Skip rather than fail if prereqs not found. + * automated/Makefile.in (emacs): Empty EMACSLOADPATH rather than unsetting. === modified file 'test/automated/python-tests.el' --- test/automated/python-tests.el 2013-08-13 16:36:32 +0000 +++ test/automated/python-tests.el 2013-11-23 20:42:38 +0000 @@ -1448,9 +1448,7 @@ "Check the command to execute is calculated correctly. Using `python-shell-interpreter' and `python-shell-interpreter-args'." - :expected-result (if (executable-find python-tests-shell-interpreter) - :passed - :failed) + (skip-unless (executable-find python-tests-shell-interpreter)) (let ((python-shell-interpreter (executable-find python-tests-shell-interpreter)) (python-shell-interpreter-args "-B")) @@ -1522,9 +1520,7 @@ (ert-deftest python-shell-make-comint-1 () "Check comint creation for global shell buffer." - :expected-result (if (executable-find python-tests-shell-interpreter) - :passed - :failed) + (skip-unless (executable-find python-tests-shell-interpreter)) (let* ((python-shell-interpreter (executable-find python-tests-shell-interpreter)) (proc-name (python-shell-get-process-name nil)) @@ -1544,9 +1540,7 @@ (ert-deftest python-shell-make-comint-2 () "Check comint creation for internal shell buffer." - :expected-result (if (executable-find python-tests-shell-interpreter) - :passed - :failed) + (skip-unless (executable-find python-tests-shell-interpreter)) (let* ((python-shell-interpreter (executable-find python-tests-shell-interpreter)) (proc-name (python-shell-internal-get-process-name)) @@ -1566,9 +1560,7 @@ (ert-deftest python-shell-get-process-1 () "Check dedicated shell process preference over global." - :expected-result (if (executable-find python-tests-shell-interpreter) - :passed - :failed) + (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-file "" (let* ((python-shell-interpreter @@ -1627,9 +1619,7 @@ (ert-deftest python-shell-internal-get-or-create-process-1 () "Check internal shell process creation fallback." - :expected-result (if (executable-find python-tests-shell-interpreter) - :passed - :failed) + (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-file "" (should (not (process-live-p (python-shell-internal-get-process-name)))) ------------------------------------------------------------ revno: 115205 fixes bug: http://debbugs.gnu.org/15647 committer: Glenn Morris branch nick: trunk timestamp: Sat 2013-11-23 11:39:50 -0800 message: * python.el (python-shell-send-file): Add option to delete file when done. (python-shell-send-string, python-shell-send-region): Use it. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-11-23 04:20:31 +0000 +++ lisp/ChangeLog 2013-11-23 19:39:50 +0000 @@ -1,3 +1,9 @@ +2013-11-23 Glenn Morris + + * progmodes/python.el (python-shell-send-file): + Add option to delete file when done. (Bug#15647) + (python-shell-send-string, python-shell-send-region): Use it. + 2013-11-23 Ivan Shmakov (tiny change) * vc/diff-mode.el (diff-mode): Only allow diff-default-read-only === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2013-11-23 04:20:31 +0000 +++ lisp/progmodes/python.el 2013-11-23 19:39:50 +0000 @@ -2056,7 +2056,7 @@ (let ((process (or process (python-shell-get-or-create-process)))) (if (string-match ".\n+." string) ;Multiline. (let* ((temp-file-name (python-shell--save-temp-file string))) - (python-shell-send-file temp-file-name process temp-file-name)) + (python-shell-send-file temp-file-name process temp-file-name t)) (comint-send-string process string) (when (or (not (string-match "\n\\'" string)) (string-match "\n[ \t].*\n?\\'" string)) @@ -2212,7 +2212,7 @@ (message "Sent: %s..." (match-string 1 string)) (let* ((temp-file-name (python-shell--save-temp-file string)) (file-name (or (buffer-file-name) temp-file-name))) - (python-shell-send-file file-name process temp-file-name) + (python-shell-send-file file-name process temp-file-name t) (unless python--use-fake-loc (with-current-buffer (process-buffer process) (compilation-fake-loc (copy-marker start) temp-file-name @@ -2249,11 +2249,12 @@ (end-of-line 1)) (point-marker))))) -(defun python-shell-send-file (file-name &optional process temp-file-name) +(defun python-shell-send-file (file-name &optional process temp-file-name + delete) "Send FILE-NAME to inferior Python PROCESS. If TEMP-FILE-NAME is passed then that file is used for processing instead, while internally the shell will continue to use -FILE-NAME." +FILE-NAME. If DELETE is non-nil, delete the file afterwards." (interactive "fFile to send: ") (let* ((process (or process (python-shell-get-or-create-process))) (temp-file-name (when temp-file-name @@ -2271,8 +2272,11 @@ (format (concat "__pyfile = open('''%s''');" "exec(compile(__pyfile.read(), '''%s''', 'exec'));" - "__pyfile.close()") - (or temp-file-name file-name) file-name) + "__pyfile.close()%s") + (or temp-file-name file-name) file-name + (if delete (format "; import os; os.remove('''%s''')" + (or temp-file-name file-name)) + "")) process))) (defun python-shell-switch-to-shell () ------------------------------------------------------------ revno: 115204 author: Brian Jenkins committer: Glenn Morris branch nick: trunk timestamp: Sat 2013-11-23 11:07:34 -0800 message: Documentation for focus-in,out hooks (tiny change) * doc/lispref/frames.texi (Input Focus): * doc/lispref/hooks.texi (Standard Hooks): Mention focus-in-hook, focus-out-hook. * etc/NEWS: Copyedit. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2013-11-23 01:55:16 +0000 +++ doc/lispref/ChangeLog 2013-11-23 19:07:34 +0000 @@ -1,3 +1,8 @@ +2013-11-23 Brian Jenkins (tiny change) + + * frames.texi (Input Focus): + * hooks.texi (Standard Hooks): Mention focus-in-hook, focus-out-hook. + 2013-11-23 Glenn Morris * loading.texi (Library Search): === modified file 'doc/lispref/frames.texi' --- doc/lispref/frames.texi 2013-10-03 19:10:34 +0000 +++ doc/lispref/frames.texi 2013-11-23 19:07:34 +0000 @@ -1479,6 +1479,14 @@ change it. @end defun +@defvar focus-in-hook +This is a normal hook run when an Emacs frame gains input focus. +@end defvar + +@defvar focus-out-hook +This is a normal hook run when an Emacs frame loses input focus. +@end defvar + @defopt focus-follows-mouse This option is how you inform Emacs whether the window manager transfers focus when the user moves the mouse. Non-@code{nil} says that it does. === modified file 'doc/lispref/hooks.texi' --- doc/lispref/hooks.texi 2013-01-05 08:37:05 +0000 +++ doc/lispref/hooks.texi 2013-11-23 19:07:34 +0000 @@ -115,6 +115,12 @@ @vindex delayed-warnings-hook The command loop runs this soon after @code{post-command-hook} (q.v.). +@item focus-in-hook +@vindex focus-in-hook +@itemx focus-out-hook +@vindex focus-out-hook +@xref{Input Focus}. + @item delete-frame-functions @xref{Deleting Frames}. === modified file 'etc/NEWS' --- etc/NEWS 2013-11-23 01:55:16 +0000 +++ etc/NEWS 2013-11-23 19:07:34 +0000 @@ -176,6 +176,7 @@ selected among several alternatives, as a matter of user preference. ** New hooks `focus-in-hook', `focus-out-hook'. +These are normal hooks run when an Emacs frame gains or loses input focus. ** The blink cursor stops blinking after 10 blinks (default) on X and NS. You can change the default by customizing the variable blink-cursor-blinks. ------------------------------------------------------------ revno: 115203 committer: Xue Fuqiao branch nick: trunk timestamp: Sat 2013-11-23 22:32:56 +0800 message: Tweak previous change. diff: === modified file 'etc/TODO' --- etc/TODO 2013-11-23 14:19:32 +0000 +++ etc/TODO 2013-11-23 14:32:56 +0000 @@ -545,7 +545,7 @@ Here's a list which is probably not complete/correct: align, allout, artist, ansi-color, array, calculator, cdl, cmuscheme, - completion, cua, delim-col, dirtrack, double, echistory, elide-head, + completion, delim-col, dirtrack, double, echistory, elide-head, easymenu, expand, flow-ctrl, format [format-alist], generic/generic-x [various modes], kermit, log-edit, makesum, midnight [other than in Kill Buffer node], @@ -554,7 +554,7 @@ the web page], talk, thingatpt [interactive functions?], type-break, vcursor, xscheme, zone-mode [?], mlconvert [?], iso-cvt, feedmail [?], uce, gametree, meese, page-ext, - refbib, refer, scribe, sgml-mode, spell, texinfo, underline, + refbib, refer, scribe, spell [obsolete?], texinfo, underline, cmacexp, hideif, mantemp [obsolete?], pcomplete, xml, cvs-status (should be described in PCL-CVS manual); other progmodes, probably in separate manual. ------------------------------------------------------------ revno: 115202 committer: Xue Fuqiao branch nick: trunk timestamp: Sat 2013-11-23 22:19:32 +0800 message: * etc/TODO: Minor update. diff: === modified file 'doc/emacs/emacs.texi' --- doc/emacs/emacs.texi 2013-10-13 00:31:19 +0000 +++ doc/emacs/emacs.texi 2013-11-23 14:19:32 +0000 @@ -115,6 +115,7 @@ some of the ways to customize it; it corresponds to GNU Emacs version @value{EMACSVER}. +@c See `manual-html-mono' and `manual-html-node' in admin/admin.el. @ifset WWW_GNU_ORG @html The homepage for GNU Emacs is at === modified file 'etc/ChangeLog' --- etc/ChangeLog 2013-11-23 02:21:51 +0000 +++ etc/ChangeLog 2013-11-23 14:19:32 +0000 @@ -1,3 +1,7 @@ +2013-11-23 Xue Fuqiao + + * TODO: Minor update. + 2013-11-23 Glenn Morris * enriched.txt: Rename from enriched.doc. (Bug#15947) === modified file 'etc/TODO' --- etc/TODO 2013-11-17 19:34:36 +0000 +++ etc/TODO 2013-11-23 14:19:32 +0000 @@ -544,7 +544,7 @@ aim for completeness, but some may be worth documenting. Here's a list which is probably not complete/correct: align, allout, - artist, ansi-color, array, battery, calculator, cdl, cmuscheme, + artist, ansi-color, array, calculator, cdl, cmuscheme, completion, cua, delim-col, dirtrack, double, echistory, elide-head, easymenu, expand, flow-ctrl, format [format-alist], generic/generic-x [various modes], kermit, log-edit, ------------------------------------------------------------ revno: 115201 committer: Romain Francoise branch nick: trunk timestamp: Sat 2013-11-23 12:32:05 +0100 message: Really initialize `write_region_inhibit_fsync' when interactive. * fileio.c (init_fileio): Move `write_region_inhibit_fsync' initialization here ... (syms_of_fileio): ... from here. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-11-23 03:23:20 +0000 +++ src/ChangeLog 2013-11-23 11:32:05 +0000 @@ -1,3 +1,9 @@ +2013-11-23 Romain Francoise + + * fileio.c (init_fileio): Move `write_region_inhibit_fsync' + initialization here ... + (syms_of_fileio): ... from here. + 2013-11-23 Stefan Monnier * lread.c (init_lread): Fix int/Lisp_Object mixup. === modified file 'src/fileio.c' --- src/fileio.c 2013-11-09 11:12:33 +0000 +++ src/fileio.c 2013-11-23 11:32:05 +0000 @@ -5773,6 +5773,24 @@ init_fileio (void) { valid_timestamp_file_system = 0; + + /* fsync can be a significant performance hit. Often it doesn't + suffice to make the file-save operation survive a crash. For + batch scripts, which are typically part of larger shell commands + that don't fsync other files, its effect on performance can be + significant so its utility is particularly questionable. + Hence, for now by default fsync is used only when interactive. + + For more on why fsync often fails to work on today's hardware, see: + Zheng M et al. Understanding the robustness of SSDs under power fault. + 11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84 + http://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf + + For more on why fsync does not suffice even if it works properly, see: + Roche X. Necessary step(s) to synchronize filename operations on disk. + Austin Group Defect 672, 2013-03-19 + http://austingroupbugs.net/view.php?id=672 */ + write_region_inhibit_fsync = noninteractive; } void @@ -5985,28 +6003,12 @@ file is usually more useful if it contains the deleted text. */); Vauto_save_include_big_deletions = Qnil; - /* fsync can be a significant performance hit. Often it doesn't - suffice to make the file-save operation survive a crash. For - batch scripts, which are typically part of larger shell commands - that don't fsync other files, its effect on performance can be - significant so its utility is particularly questionable. - Hence, for now by default fsync is used only when interactive. - - For more on why fsync often fails to work on today's hardware, see: - Zheng M et al. Understanding the robustness of SSDs under power fault. - 11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84 - http://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf - - For more on why fsync does not suffice even if it works properly, see: - Roche X. Necessary step(s) to synchronize filename operations on disk. - Austin Group Defect 672, 2013-03-19 - http://austingroupbugs.net/view.php?id=672 */ DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync, doc: /* Non-nil means don't call fsync in `write-region'. This variable affects calls to `write-region' as well as save commands. Setting this to nil may avoid data loss if the system loses power or the operating system crashes. */); - write_region_inhibit_fsync = noninteractive; + write_region_inhibit_fsync = 0; /* See also `init_fileio' above. */ DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash, doc: /* Specifies whether to use the system's trash can. ------------------------------------------------------------ revno: 115200 committer: Glenn Morris branch nick: trunk timestamp: Fri 2013-11-22 20:20:31 -0800 message: Revert previous python.el change diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-11-23 03:13:16 +0000 +++ lisp/ChangeLog 2013-11-23 04:20:31 +0000 @@ -1,8 +1,3 @@ -2013-11-23 Jorgen Schaefer (tiny change) - - * progmodes/python.el (python-shell--save-temp-file): - Delete temp-file when done. (Bug#15647) - 2013-11-23 Ivan Shmakov (tiny change) * vc/diff-mode.el (diff-mode): Only allow diff-default-read-only === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2013-11-23 03:13:16 +0000 +++ lisp/progmodes/python.el 2013-11-23 04:20:31 +0000 @@ -2046,8 +2046,6 @@ (with-temp-file temp-file-name (insert "# -*- coding: utf-8 -*-\n") ;Not needed for Python-3. (insert string) - (insert (format "\n\nimport os ; os.remove('''%s''')\n" - temp-file-name)) (delete-trailing-whitespace)) temp-file-name))