Now on revision 113386. ------------------------------------------------------------ revno: 113386 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 23:45:04 -0700 message: * admin/admin.el (manual-style-string): Use non-abbreviated url. diff: === modified file 'admin/ChangeLog' --- admin/ChangeLog 2013-07-09 17:16:21 +0000 +++ admin/ChangeLog 2013-07-12 06:45:04 +0000 @@ -1,3 +1,7 @@ +2013-07-12 Glenn Morris + + * admin.el (manual-style-string): Use non-abbreviated url. + 2013-07-09 Paul Eggert Port recent close-on-exec changes to Cygwin (Bug#14821). === modified file 'admin/admin.el' --- admin/admin.el 2013-07-06 18:28:54 +0000 +++ admin/admin.el 2013-07-12 06:45:04 +0000 @@ -283,7 +283,7 @@ \n\n") (defconst manual-style-string "\n") +@import url('/software/emacs/manual.css');\n\n") (defun manual-misc-html (name root html-node-dir html-mono-dir) ;; Hack to deal with the cases where .texi creates a different .info. ------------------------------------------------------------ revno: 113385 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 20:54:57 -0700 message: Remove some more reimplementations of cl-lib functions * lisp/doc-view.el: Require cl-lib at runtime too. (doc-view-remove-if): Remove. (doc-view-search-next-match, doc-view-search-previous-match): Use cl-remove-if. * lisp/edmacro.el: Require cl-lib at runtime too. (edmacro-format-keys, edmacro-parse-keys): Use cl-mismatch, cl-subseq. (edmacro-mismatch, edmacro-subseq): Remove. * lisp/filesets.el: Comments. * lisp/shadowfile.el: Require cl-lib. (shadow-remove-if): Remove. (shadow-set-cluster, shadow-shadows-of-1, shadow-remove-from-todo): Use cl-remove-if. * lisp/wid-edit.el: Require cl-lib. (widget-choose): Use cl-remove-if. (widget-remove-if): Remove. * lisp/progmodes/ebrowse.el: Require cl-lib at runtime too. (ebrowse-delete-if-not): Remove. (ebrowse-browser-buffer-list, ebrowse-member-buffer-list) (ebrowse-tree-buffer-list, ebrowse-same-tree-member-buffer-list): Use cl-delete-if-not. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-12 01:11:22 +0000 +++ lisp/ChangeLog 2013-07-12 03:54:57 +0000 @@ -1,3 +1,29 @@ +2013-07-12 Glenn Morris + + * doc-view.el: Require cl-lib at runtime too. + (doc-view-remove-if): Remove. + (doc-view-search-next-match, doc-view-search-previous-match): + Use cl-remove-if. + + * edmacro.el: Require cl-lib at runtime too. + (edmacro-format-keys, edmacro-parse-keys): Use cl-mismatch, cl-subseq. + (edmacro-mismatch, edmacro-subseq): Remove. + + * shadowfile.el: Require cl-lib. + (shadow-remove-if): Remove. + (shadow-set-cluster, shadow-shadows-of-1, shadow-remove-from-todo): + Use cl-remove-if. + + * wid-edit.el: Require cl-lib. + (widget-choose): Use cl-remove-if. + (widget-remove-if): Remove. + + * progmodes/ebrowse.el: Require cl-lib at runtime too. + (ebrowse-delete-if-not): Remove. + (ebrowse-browser-buffer-list, ebrowse-member-buffer-list) + (ebrowse-tree-buffer-list, ebrowse-same-tree-member-buffer-list): + Use cl-delete-if-not. + 2013-07-12 Juanma Barranquero * emacs-lisp/cl-macs.el (cl-multiple-value-bind, cl-multiple-value-setq) === modified file 'lisp/doc-view.el' --- lisp/doc-view.el 2013-05-27 01:08:43 +0000 +++ lisp/doc-view.el 2013-07-12 03:54:57 +0000 @@ -136,7 +136,7 @@ ;;; Code: -(eval-when-compile (require 'cl-lib)) +(require 'cl-lib) (require 'dired) (require 'image-mode) (require 'jka-compr) @@ -698,14 +698,6 @@ (md5 (current-buffer))))) doc-view-cache-directory))))) -(defun doc-view-remove-if (predicate list) - "Return LIST with all items removed that satisfy PREDICATE." - (let (new-list) - (dolist (item list) - (when (not (funcall predicate item)) - (setq new-list (cons item new-list)))) - (nreverse new-list))) - ;;;###autoload (defun doc-view-mode-p (type) "Return non-nil if document type TYPE is available for `doc-view'. @@ -1488,7 +1480,7 @@ (defun doc-view-search-next-match (arg) "Go to the ARGth next matching page." (interactive "p") - (let* ((next-pages (doc-view-remove-if + (let* ((next-pages (cl-remove-if (lambda (i) (<= (car i) (doc-view-current-page))) doc-view--current-search-matches)) (page (car (nth (1- arg) next-pages)))) @@ -1502,7 +1494,7 @@ (defun doc-view-search-previous-match (arg) "Go to the ARGth previous matching page." (interactive "p") - (let* ((prev-pages (doc-view-remove-if + (let* ((prev-pages (cl-remove-if (lambda (i) (>= (car i) (doc-view-current-page))) doc-view--current-search-matches)) (page (car (nth (1- arg) (nreverse prev-pages))))) === modified file 'lisp/edmacro.el' --- lisp/edmacro.el 2013-01-01 09:11:05 +0000 +++ lisp/edmacro.el 2013-07-12 03:54:57 +0000 @@ -62,9 +62,8 @@ ;; macro in a more concise way that omits the comments. ;;; Code: - -(eval-when-compile (require 'cl-lib)) +(require 'cl-lib) (require 'kmacro) ;;; The user-level commands for editing macros. @@ -444,14 +443,14 @@ (let* ((prefix (or (and (integerp (aref rest-mac 0)) (memq (aref rest-mac 0) mdigs) - (memq (key-binding (edmacro-subseq rest-mac 0 1)) + (memq (key-binding (cl-subseq rest-mac 0 1)) '(digit-argument negative-argument)) (let ((i 1)) (while (memq (aref rest-mac i) (cdr mdigs)) (cl-incf i)) (and (not (memq (aref rest-mac i) pkeys)) - (prog1 (vconcat "M-" (edmacro-subseq rest-mac 0 i) " ") - (cl-callf edmacro-subseq rest-mac i))))) + (prog1 (vconcat "M-" (cl-subseq rest-mac 0 i) " ") + (cl-callf cl-subseq rest-mac i))))) (and (eq (aref rest-mac 0) ?\C-u) (eq (key-binding [?\C-u]) 'universal-argument) (let ((i 1)) @@ -459,7 +458,7 @@ (cl-incf i)) (and (not (memq (aref rest-mac i) pkeys)) (prog1 (cl-loop repeat i concat "C-u ") - (cl-callf edmacro-subseq rest-mac i))))) + (cl-callf cl-subseq rest-mac i))))) (and (eq (aref rest-mac 0) ?\C-u) (eq (key-binding [?\C-u]) 'universal-argument) (let ((i 1)) @@ -469,18 +468,18 @@ '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) (cl-incf i)) (and (not (memq (aref rest-mac i) pkeys)) - (prog1 (vconcat "C-u " (edmacro-subseq rest-mac 1 i) " ") - (cl-callf edmacro-subseq rest-mac i))))))) + (prog1 (vconcat "C-u " (cl-subseq rest-mac 1 i) " ") + (cl-callf cl-subseq rest-mac i))))))) (bind-len (apply 'max 1 (cl-loop for map in maps for b = (lookup-key map rest-mac) when b collect b))) - (key (edmacro-subseq rest-mac 0 bind-len)) + (key (cl-subseq rest-mac 0 bind-len)) (fkey nil) tlen tkey (bind (or (cl-loop for map in maps for b = (lookup-key map key) thereis (and (not (integerp b)) b)) (and (setq fkey (lookup-key local-function-key-map rest-mac)) - (setq tlen fkey tkey (edmacro-subseq rest-mac 0 tlen) + (setq tlen fkey tkey (cl-subseq rest-mac 0 tlen) fkey (lookup-key local-function-key-map tkey)) (cl-loop for map in maps for b = (lookup-key map fkey) @@ -507,7 +506,7 @@ (> first 32) (<= first maxkey) (/= first 92) (progn (if (> text 30) (setq text 30)) - (setq desc (concat (edmacro-subseq rest-mac 0 text))) + (setq desc (concat (cl-subseq rest-mac 0 text))) (when (string-match "^[ACHMsS]-." desc) (setq text 2) (cl-callf substring desc 0 2)) @@ -524,7 +523,7 @@ (> text bind-len) (memq (aref rest-mac text) '(return 13)) (progn - (setq desc (concat (edmacro-subseq rest-mac bind-len text))) + (setq desc (concat (cl-subseq rest-mac bind-len text))) (commandp (intern-soft desc)))) (if (commandp (intern-soft desc)) (setq bind desc)) (setq desc (format "<<%s>>" desc)) @@ -562,14 +561,14 @@ (setq desc (concat (edmacro-sanitize-for-string prefix) desc))) (unless (string-match " " desc) (let ((times 1) (pos bind-len)) - (while (not (edmacro-mismatch rest-mac rest-mac + (while (not (cl-mismatch rest-mac rest-mac 0 bind-len pos (+ bind-len pos))) (cl-incf times) (cl-incf pos bind-len)) (when (> times 1) (setq desc (format "%d*%s" times desc)) (setq bind-len (* bind-len times))))) - (setq rest-mac (edmacro-subseq rest-mac bind-len)) + (setq rest-mac (cl-subseq rest-mac bind-len)) (if verbose (progn (unless (equal res "") (cl-callf concat res "\n")) @@ -590,50 +589,6 @@ (cl-incf len (length desc))))) res)) -(defun edmacro-mismatch (cl-seq1 cl-seq2 cl-start1 cl-end1 cl-start2 cl-end2) - "Compare SEQ1 with SEQ2, return index of first mismatching element. -Return nil if the sequences match. If one sequence is a prefix of the -other, the return value indicates the end of the shorted sequence. -\n(fn SEQ1 SEQ2 START1 END1 START2 END2)" - (or cl-end1 (setq cl-end1 (length cl-seq1))) - (or cl-end2 (setq cl-end2 (length cl-seq2))) - (let ((cl-p1 (and (listp cl-seq1) (nthcdr cl-start1 cl-seq1))) - (cl-p2 (and (listp cl-seq2) (nthcdr cl-start2 cl-seq2)))) - (while (and (< cl-start1 cl-end1) (< cl-start2 cl-end2) - (eql (if cl-p1 (car cl-p1) - (aref cl-seq1 cl-start1)) - (if cl-p2 (car cl-p2) - (aref cl-seq2 cl-start2)))) - (setq cl-p1 (cdr cl-p1) cl-p2 (cdr cl-p2) - cl-start1 (1+ cl-start1) cl-start2 (1+ cl-start2))) - (and (or (< cl-start1 cl-end1) (< cl-start2 cl-end2)) - cl-start1))) - -(defun edmacro-subseq (seq start &optional end) - "Return the subsequence of SEQ from START to END. -If END is omitted, it defaults to the length of the sequence. -If START or END is negative, it counts from the end." - (if (stringp seq) (substring seq start end) - (let (len) - (and end (< end 0) (setq end (+ end (setq len (length seq))))) - (if (< start 0) (setq start (+ start (or len (setq len (length seq)))))) - (cond ((listp seq) - (if (> start 0) (setq seq (nthcdr start seq))) - (if end - (let ((res nil)) - (while (>= (setq end (1- end)) start) - (push (pop seq) res)) - (nreverse res)) - (copy-sequence seq))) - (t - (or end (setq end (or len (length seq)))) - (let ((res (make-vector (max (- end start) 0) nil)) - (i 0)) - (while (< start end) - (aset res i (aref seq start)) - (setq i (1+ i) start (1+ start))) - res)))))) - (defun edmacro-sanitize-for-string (seq) "Convert a key sequence vector SEQ into a string. The string represents the same events; Meta is indicated by bit 7. @@ -760,7 +715,7 @@ (eq (aref res 1) ?\() (eq (aref res (- (length res) 2)) ?\C-x) (eq (aref res (- (length res) 1)) ?\))) - (setq res (edmacro-subseq res 2 -2))) + (setq res (cl-subseq res 2 -2))) (if (and (not need-vector) (cl-loop for ch across res always (and (characterp ch) === modified file 'lisp/filesets.el' --- lisp/filesets.el 2013-03-05 17:13:01 +0000 +++ lisp/filesets.el 2013-07-12 03:54:57 +0000 @@ -149,7 +149,7 @@ (defun filesets-filter-list (lst cond-fn) "Remove all elements not conforming to COND-FN from list LST. COND-FN takes one argument: the current element." -; (remove* 'dummy lst :test (lambda (dummy elt) +; (cl-remove 'dummy lst :test (lambda (dummy elt) ; (not (funcall cond-fn elt))))) (let ((rv nil)) (dolist (elt lst rv) @@ -175,7 +175,7 @@ (let ((fss-rv (funcall fss-pred fss-this))) (when fss-rv (throw 'exit fss-rv)))))) -;(fset 'filesets-some 'some) ;; or use the cl function +;(fset 'filesets-some 'cl-some) ;; or use the cl function (defun filesets-member (fsm-item fsm-lst &rest fsm-keys) "Find the first occurrence of FSM-ITEM in FSM-LST. @@ -186,7 +186,7 @@ (filesets-ormap (lambda (fsm-this) (funcall fsm-test fsm-item fsm-this)) fsm-lst))) -;(fset 'filesets-member 'member*) ;; or use the cl function +;(fset 'filesets-member 'cl-member) ;; or use the cl function (defun filesets-sublist (lst beg &optional end) "Get the sublist of LST from BEG to END - 1." === modified file 'lisp/progmodes/ebrowse.el' --- lisp/progmodes/ebrowse.el 2013-01-01 09:11:05 +0000 +++ lisp/progmodes/ebrowse.el 2013-07-12 03:54:57 +0000 @@ -33,12 +33,12 @@ ;;; Code: +(require 'cl-lib) (require 'easymenu) (require 'view) (require 'ebuff-menu) (eval-when-compile - (require 'cl-lib) (require 'helper)) @@ -233,19 +233,6 @@ found)) -(defun ebrowse-delete-if-not (predicate list) - "Remove elements not satisfying PREDICATE from LIST and return the result. -This is a destructive operation." - (let (result) - (while list - (let ((next (cdr list))) - (when (funcall predicate (car list)) - (setq result (nconc result list)) - (setf (cdr list) nil)) - (setq list next))) - result)) - - (defmacro ebrowse-output (&rest body) "Eval BODY with a writable current buffer. Preserve buffer's modified state." @@ -1310,17 +1297,17 @@ (defun ebrowse-browser-buffer-list () "Return a list of all tree or member buffers." - (ebrowse-delete-if-not 'ebrowse-buffer-p (buffer-list))) + (cl-delete-if-not 'ebrowse-buffer-p (buffer-list))) (defun ebrowse-member-buffer-list () "Return a list of all member buffers." - (ebrowse-delete-if-not 'ebrowse-member-buffer-p (buffer-list))) + (cl-delete-if-not 'ebrowse-member-buffer-p (buffer-list))) (defun ebrowse-tree-buffer-list () "Return a list of all tree buffers." - (ebrowse-delete-if-not 'ebrowse-tree-buffer-p (buffer-list))) + (cl-delete-if-not 'ebrowse-tree-buffer-p (buffer-list))) (defun ebrowse-known-class-trees-buffer-list () @@ -1341,7 +1328,7 @@ (defun ebrowse-same-tree-member-buffer-list () "Return a list of members buffers with same tree as current buffer." - (ebrowse-delete-if-not + (cl-delete-if-not (lambda (buffer) (eq (buffer-local-value 'ebrowse--tree buffer) ebrowse--tree)) === modified file 'lisp/shadowfile.el' --- lisp/shadowfile.el 2013-03-12 02:08:21 +0000 +++ lisp/shadowfile.el 2013-07-12 03:54:57 +0000 @@ -74,6 +74,7 @@ ;;; Code: +(require 'cl-lib) (require 'ange-ftp) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -180,15 +181,6 @@ (setq list (cdr list))) (car list)) -(defun shadow-remove-if (func list) - "Remove elements satisfying FUNC from LIST. -Nondestructive; actually returns a copy of the list with the elements removed." - (if list - (if (funcall func (car list)) - (shadow-remove-if func (cdr list)) - (cons (car list) (shadow-remove-if func (cdr list)))) - nil)) - (defun shadow-regexp-superquote (string) "Like `regexp-quote', but includes the ^ and $. This makes sure regexp matches nothing but STRING." @@ -238,9 +230,8 @@ Replace old definition, if any. PRIMARY and REGEXP are the information defining the cluster. For interactive use, call `shadow-define-cluster' instead." - (let ((rest (shadow-remove-if - (function (lambda (x) (equal name (car x)))) - shadow-clusters))) + (let ((rest (cl-remove-if (lambda (x) (equal name (car x))) + shadow-clusters))) (setq shadow-clusters (cons (shadow-make-cluster name primary regexp) rest)))) @@ -602,9 +593,8 @@ Consider them as regular expressions if third arg REGEXP is true." (if groups (let ((nonmatching - (shadow-remove-if - (function (lambda (x) (shadow-file-match x file regexp))) - (car groups)))) + (cl-remove-if (lambda (x) (shadow-file-match x file regexp)) + (car groups)))) (append (cond ((equal nonmatching (car groups)) nil) (regexp (let ((realname (nth 2 (shadow-parse-fullname file)))) @@ -635,8 +625,7 @@ "Remove PAIR from `shadow-files-to-copy'. PAIR must be `eq' to one of the elements of that list." (setq shadow-files-to-copy - (shadow-remove-if (function (lambda (s) (eq s pair))) - shadow-files-to-copy))) + (cl-remove-if (lambda (s) (eq s pair)) shadow-files-to-copy))) (defun shadow-read-files () "Visit and load `shadow-info-file' and `shadow-todo-file'. === modified file 'lisp/wid-edit.el' --- lisp/wid-edit.el 2013-07-01 05:00:50 +0000 +++ lisp/wid-edit.el 2013-07-12 03:54:57 +0000 @@ -55,6 +55,7 @@ ;; See `widget.el'. ;;; Code: +(require 'cl-lib) ;;; Compatibility. @@ -221,7 +222,7 @@ ((or widget-menu-minibuffer-flag (> (length items) widget-menu-max-shortcuts)) ;; Read the choice of name from the minibuffer. - (setq items (widget-remove-if 'stringp items)) + (setq items (cl-remove-if 'stringp items)) (let ((val (completing-read (concat title ": ") items nil t))) (if (stringp val) (let ((try (try-completion val items))) @@ -295,14 +296,6 @@ (error "Canceled")) value)))) -(defun widget-remove-if (predicate list) - (let (result (tail list)) - (while tail - (or (funcall predicate (car tail)) - (setq result (cons (car tail) result))) - (setq tail (cdr tail))) - (nreverse result))) - ;;; Widget text specifications. ;; ;; These functions are for specifying text properties. ------------------------------------------------------------ revno: 113384 committer: Paul Eggert branch nick: trunk timestamp: Thu 2013-07-11 19:03:47 -0700 message: Fix races with threads and file descriptors. * configure.ac (PTY_TTY_NAME_SPRINTF): Use emacs_close, not close. * src/callproc.c (Fcall_process_region): * src/dired.c (open_directory): * src/emacs.c (main, Fdaemon_initialized): * src/image.c (x_find_image_file): * src/inotify.c (Finotify_rm_watch): * src/lread.c (Flocate_file_internal): * src/process.c (Fnetwork_interface_list, Fnetwork_interface_info): * src/term.c (term_mouse_moveto, init_tty): * src/termcap.c (tgetent): * src/unexaix.c, src/unexcoff.c (report_error, report_error_1, adjust_lnnoptrs) * src/unexaix.c, src/unexcoff.c, src/unexcw.c, src/unexelf.c (unexec): * src/unexhp9k800.c, src/unexmacosx.c (unexec): * src/callproc.c (Fcall_process_region): Use emacs_close, not close. * src/sysdep.c (POSIX_CLOSE_RESTART, posix_close) [!POSIX_CLOSE_RESTART]: New macro and function, which emulates the POSIX_CLOSE_RESTART macro and posix_close function on current platforms (which all lack them). (emacs_close): Use it. This should fix the races on GNU/Linux and on AIX and on future platforms that support POSIX_CLOSE_RESTART, and it should avoid closing random victim file descriptors on other platforms. diff: === modified file 'ChangeLog' --- ChangeLog 2013-07-11 17:18:48 +0000 +++ ChangeLog 2013-07-12 02:03:47 +0000 @@ -1,3 +1,8 @@ +2013-07-12 Paul Eggert + + Fix races with threads and file descriptors. + * configure.ac (PTY_TTY_NAME_SPRINTF): Use emacs_close, not close. + 2013-07-10 Paul Eggert * Makefile.in (removenullpaths): Remove adjacent null paths (Bug#14835). === modified file 'configure.ac' --- configure.ac 2013-07-09 18:06:25 +0000 +++ configure.ac 2013-07-12 02:03:47 +0000 @@ -3931,7 +3931,7 @@ AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)]) dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD dnl to prevent sigchld_handler from intercepting the child's death. - AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }]) + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }]) dnl if HAVE_POSIX_OPENPT if test "x$ac_cv_func_posix_openpt" = xyes; then AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY)]) === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-11 17:28:58 +0000 +++ src/ChangeLog 2013-07-12 02:03:47 +0000 @@ -1,3 +1,28 @@ +2013-07-12 Paul Eggert + + Fix races with threads and file descriptors. + * callproc.c (Fcall_process_region): + * dired.c (open_directory): + * emacs.c (main, Fdaemon_initialized): + * image.c (x_find_image_file): + * inotify.c (Finotify_rm_watch): + * lread.c (Flocate_file_internal): + * process.c (Fnetwork_interface_list, Fnetwork_interface_info): + * term.c (term_mouse_moveto, init_tty): + * termcap.c (tgetent): + * unexaix.c, unexcoff.c (report_error, report_error_1, adjust_lnnoptrs) + * unexaix.c, unexcoff.c, unexcw.c, unexelf.c (unexec): + * unexhp9k800.c, unexmacosx.c (unexec): + * callproc.c (Fcall_process_region): + Use emacs_close, not close. + * sysdep.c (POSIX_CLOSE_RESTART, posix_close) [!POSIX_CLOSE_RESTART]: + New macro and function, which emulates the POSIX_CLOSE_RESTART macro + and posix_close function on current platforms (which all lack them). + (emacs_close): Use it. This should fix the races on GNU/Linux and + on AIX and on future platforms that support POSIX_CLOSE_RESTART, + and it should avoid closing random victim file descriptors on + other platforms. + 2013-07-11 Paul Eggert * inotify.c (uninitialized): Remove. All uses replaced by -1. === modified file 'src/callproc.c' --- src/callproc.c 2013-07-09 07:04:48 +0000 +++ src/callproc.c 2013-07-12 02:03:47 +0000 @@ -1052,7 +1052,7 @@ report_file_error ("Failed to open temporary file", Fcons (build_string (tempfile), Qnil)); else - close (fd); + emacs_close (fd); } #else errno = 0; === modified file 'src/dired.c' --- src/dired.c 2013-04-02 01:54:56 +0000 +++ src/dired.c 2013-07-12 02:03:47 +0000 @@ -95,7 +95,7 @@ d = fdopendir (fd); opendir_errno = errno; if (! d) - close (fd); + emacs_close (fd); } #endif === modified file 'src/emacs.c' --- src/emacs.c 2013-07-10 23:23:57 +0000 +++ src/emacs.c 2013-07-12 02:03:47 +0000 @@ -1010,7 +1010,7 @@ char buf[1]; /* Close unused writing end of the pipe. */ - close (daemon_pipe[1]); + emacs_close (daemon_pipe[1]); /* Just wait for the child to close its end of the pipe. */ do @@ -1030,7 +1030,7 @@ exit (1); } - close (daemon_pipe[0]); + emacs_close (daemon_pipe[0]); exit (0); } if (f < 0) @@ -1080,7 +1080,7 @@ if (dname_arg) daemon_name = xstrdup (dname_arg); /* Close unused reading end of the pipe. */ - close (daemon_pipe[0]); + emacs_close (daemon_pipe[0]); setsid (); #else /* DOS_NT */ @@ -2254,7 +2254,7 @@ err |= dup2 (nfd, 0) < 0; err |= dup2 (nfd, 1) < 0; err |= dup2 (nfd, 2) < 0; - err |= close (nfd) != 0; + err |= emacs_close (nfd) != 0; /* Closing the pipe will notify the parent that it can exit. FIXME: In case some other process inherited the pipe, closing it here @@ -2264,7 +2264,7 @@ call-process to make sure the pipe is never inherited by subprocesses. */ err |= write (daemon_pipe[1], "\n", 1) < 0; - err |= close (daemon_pipe[1]) != 0; + err |= emacs_close (daemon_pipe[1]) != 0; /* Set it to an invalid value so we know we've already run this function. */ daemon_pipe[1] = -1; === modified file 'src/image.c' --- src/image.c 2013-07-09 05:04:45 +0000 +++ src/image.c 2013-07-12 02:03:47 +0000 @@ -2260,7 +2260,7 @@ else { file_found = ENCODE_FILE (file_found); - close (fd); + emacs_close (fd); } return file_found; === modified file 'src/inotify.c' --- src/inotify.c 2013-07-11 17:28:58 +0000 +++ src/inotify.c 2013-07-12 02:03:47 +0000 @@ -387,7 +387,7 @@ /* Cleanup if no more files are watched. */ if (NILP (watch_list)) { - close (inotifyfd); + emacs_close (inotifyfd); delete_read_fd (inotifyfd); inotifyfd = -1; } === modified file 'src/lread.c' --- src/lread.c 2013-07-10 23:23:57 +0000 +++ src/lread.c 2013-07-12 02:03:47 +0000 @@ -1413,7 +1413,7 @@ Lisp_Object file; int fd = openp (path, filename, suffixes, &file, predicate); if (NILP (predicate) && fd > 0) - close (fd); + emacs_close (fd); return file; } === modified file 'src/process.c' --- src/process.c 2013-07-09 07:04:48 +0000 +++ src/process.c 2013-07-12 02:03:47 +0000 @@ -3555,14 +3555,14 @@ ifconf.ifc_len = buf_size; if (ioctl (s, SIOCGIFCONF, &ifconf)) { - close (s); + emacs_close (s); xfree (buf); return Qnil; } } while (ifconf.ifc_len == buf_size); - close (s); + emacs_close (s); res = Qnil; ifreq = ifconf.ifc_req; @@ -3819,7 +3819,7 @@ #endif res = Fcons (elt, res); - close (s); + emacs_close (s); return any ? res : Qnil; } === modified file 'src/sysdep.c' --- src/sysdep.c 2013-07-11 02:17:47 +0000 +++ src/sysdep.c 2013-07-12 02:03:47 +0000 @@ -2201,23 +2201,59 @@ return fd < 0 ? 0 : fdopen (fd, mode); } +/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs. + For the background behind this mess, please see Austin Group defect 529 + . */ + +#ifndef POSIX_CLOSE_RESTART +# define POSIX_CLOSE_RESTART 1 +static int +posix_close (int fd, int flag) +{ + /* Only the POSIX_CLOSE_RESTART case is emulated. */ + eassert (flag == POSIX_CLOSE_RESTART); + + /* Things are tricky if close (fd) returns -1 with errno == EINTR + on a system that does not define POSIX_CLOSE_RESTART. + + In this case, in some systems (e.g., GNU/Linux, AIX) FD is + closed, and retrying the close could inadvertently close a file + descriptor allocated by some other thread. In other systems + (e.g., HP/UX) FD is not closed. And in still other systems + (e.g., OS X, Solaris), maybe FD is closed, maybe not, and in a + multithreaded program there can be no way to tell. + + So, in this case, pretend that the close succeeded. This works + well on systems like GNU/Linux that close FD. Although it may + leak a file descriptor on other systems, the leak is unlikely and + it's better to leak than to close a random victim. */ + return close (fd) == 0 || errno == EINTR ? 0 : -1; +} +#endif + +/* Close FD, retrying if interrupted. If successful, return 0; + otherwise, return -1 and set errno to a non-EINTR value. Consider + an EINPROGRESS error to be successful, as that's merely a signal + arriving. FD is always closed when this function returns, even + when it returns -1. + + Do not call this function if FD might already be closed, as that + might close an innocent victim opened by some other thread. */ + int emacs_close (int fd) { - bool did_retry = 0; - int rtnval; - - while ((rtnval = close (fd)) == -1 - && (errno == EINTR)) - did_retry = 1; - - /* If close is interrupted SunOS 4.1 may or may not have closed the - file descriptor. If it did the second close will fail with - errno = EBADF. That means we have succeeded. */ - if (rtnval == -1 && did_retry && errno == EBADF) - return 0; - - return rtnval; + while (1) + { + int r = posix_close (fd, POSIX_CLOSE_RESTART); + if (r == 0) + return r; + if (!POSIX_CLOSE_RESTART || errno != EINTR) + { + eassert (errno != EBADF); + return errno == EINPROGRESS ? 0 : r; + } + } } /* Maximum number of bytes to read or write in a single system call. === modified file 'src/term.c' --- src/term.c 2013-07-11 02:17:47 +0000 +++ src/term.c 2013-07-12 02:03:47 +0000 @@ -2478,7 +2478,7 @@ name = (const char *) ttyname (0); fd = emacs_open (name, O_WRONLY, 0); SOME_FUNCTION (x, y, fd); - close (fd); + emacs_close (fd); last_mouse_x = x; last_mouse_y = y; */ } @@ -3012,7 +3012,7 @@ name); if (!isatty (fd)) { - close (fd); + emacs_close (fd); maybe_fatal (must_succeed, terminal, "Not a tty device: %s", "Not a tty device: %s", === modified file 'src/termcap.c' --- src/termcap.c 2013-07-11 02:17:47 +0000 +++ src/termcap.c 2013-07-12 02:03:47 +0000 @@ -455,7 +455,7 @@ /* Scan the file, reading it via buf, till find start of main entry. */ if (scan_file (term, fd, &buf) == 0) { - close (fd); + emacs_close (fd); xfree (buf.beg); if (malloc_size) xfree (bp); @@ -493,7 +493,7 @@ term = tgetst1 (tc_search_point, (char **) 0); } - close (fd); + emacs_close (fd); xfree (buf.beg); if (malloc_size) === modified file 'src/unexaix.c' --- src/unexaix.c 2013-07-06 02:40:50 +0000 +++ src/unexaix.c 2013-07-12 02:03:47 +0000 @@ -97,7 +97,7 @@ if (fd) { int failed_errno = errno; - close (fd); + emacs_close (fd); errno = failed_errno; } report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); @@ -111,7 +111,7 @@ report_error_1 (int fd, const char *msg, ...) { va_list ap; - close (fd); + emacs_close (fd); va_start (ap, msg); verror (msg, ap); va_end (ap); @@ -148,13 +148,13 @@ || adjust_lnnoptrs (new, a_out, new_name) < 0 || unrelocate_symbols (new, a_out, a_name, new_name) < 0) { - close (new); + emacs_close (new); return; } - close (new); + emacs_close (new); if (a_out >= 0) - close (a_out); + emacs_close (a_out); mark_x (new_name); } @@ -534,7 +534,7 @@ } } } - close (new); + emacs_close (new); return 0; } === modified file 'src/unexcoff.c' --- src/unexcoff.c 2013-07-06 02:40:50 +0000 +++ src/unexcoff.c 2013-07-12 02:03:47 +0000 @@ -128,7 +128,7 @@ report_error (const char *file, int fd) { if (fd) - close (fd); + emacs_close (fd); report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); } @@ -139,7 +139,7 @@ static void report_error_1 (int fd, const char *msg, int a1, int a2) { - close (fd); + emacs_close (fd); error (msg, a1, a2); } @@ -511,7 +511,7 @@ } } #ifndef MSDOS - close (new); + emacs_close (new); #endif return 0; } @@ -541,13 +541,13 @@ || adjust_lnnoptrs (new, a_out, new_name) < 0 ) { - close (new); + emacs_close (new); return; } - close (new); + emacs_close (new); if (a_out >= 0) - close (a_out); + emacs_close (a_out); mark_x (new_name); } === modified file 'src/unexcw.c' --- src/unexcw.c 2013-07-06 02:40:50 +0000 +++ src/unexcw.c 2013-07-12 02:03:47 +0000 @@ -316,13 +316,13 @@ ret2 = write (fd_out, buffer, ret); assert (ret2 == ret); } - ret = close (fd_in); + ret = emacs_close (fd_in); assert (ret == 0); bss_sbrk_did_unexec = 1; fixup_executable (fd_out); bss_sbrk_did_unexec = 0; - ret = close (fd_out); + ret = emacs_close (fd_out); assert (ret == 0); } === modified file 'src/unexelf.c' --- src/unexelf.c 2013-07-06 02:40:50 +0000 +++ src/unexelf.c 2013-07-12 02:03:47 +0000 @@ -1312,13 +1312,13 @@ /* Close the files and make the new file executable. */ #if MAP_ANON == 0 - close (mmap_fd); + emacs_close (mmap_fd); #endif - if (close (old_file) != 0) + if (emacs_close (old_file) != 0) fatal ("Can't close (%s): %s", old_name, strerror (errno)); - if (close (new_file) != 0) + if (emacs_close (new_file) != 0) fatal ("Can't close (%s): %s", new_name, strerror (errno)); if (stat (new_name, &stat_buf) != 0) === modified file 'src/unexhp9k800.c' --- src/unexhp9k800.c 2013-07-06 02:40:50 +0000 +++ src/unexhp9k800.c 2013-07-12 02:03:47 +0000 @@ -306,6 +306,6 @@ write_header (new, &hdr, &auxhdr); /* Close the binary file */ - close (old); - close (new); + emacs_close (old); + emacs_close (new); } === modified file 'src/unexmacosx.c' --- src/unexmacosx.c 2013-07-06 02:40:50 +0000 +++ src/unexmacosx.c 2013-07-12 02:03:47 +0000 @@ -1332,7 +1332,7 @@ outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755); if (outfd < 0) { - close (infd); + emacs_close (infd); unexec_error ("cannot open output file `%s'", outfile); } @@ -1346,7 +1346,7 @@ dump_it (); - close (outfd); + emacs_close (outfd); } ------------------------------------------------------------ revno: 113383 committer: Juanma Barranquero branch nick: trunk timestamp: Fri 2013-07-12 03:11:22 +0200 message: lisp/emacs-lisp/cl-macs.el: Fix typos in docstrings. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-12 01:01:53 +0000 +++ lisp/ChangeLog 2013-07-12 01:11:22 +0000 @@ -1,3 +1,8 @@ +2013-07-12 Juanma Barranquero + + * emacs-lisp/cl-macs.el (cl-multiple-value-bind, cl-multiple-value-setq) + (cl-the, cl-declare, cl-defstruct): Fix typos in docstrings. + 2013-07-12 Leo Liu * ido.el (dired-do-copy, dired): Set 'ido property. (Bug#11954) === modified file 'lisp/emacs-lisp/cl-macs.el' --- lisp/emacs-lisp/cl-macs.el 2013-06-25 16:13:49 +0000 +++ lisp/emacs-lisp/cl-macs.el 2013-07-12 01:11:22 +0000 @@ -1957,7 +1957,7 @@ "Collect multiple return values. FORM must return a list; the BODY is then executed with the first N elements of this list bound (`let'-style) to each of the symbols SYM in turn. This -is analogous to the Common Lisp `cl-multiple-value-bind' macro, using lists to +is analogous to the Common Lisp `multiple-value-bind' macro, using lists to simulate true multiple return values. For compatibility, (cl-values A B C) is a synonym for (list A B C). @@ -1975,7 +1975,7 @@ "Collect multiple return values. FORM must return a list; the first N elements of this list are stored in each of the symbols SYM in turn. This is analogous to the Common Lisp -`cl-multiple-value-setq' macro, using lists to simulate true multiple return +`multiple-value-setq' macro, using lists to simulate true multiple return values. For compatibility, (cl-values A B C) is a synonym for (list A B C). \(fn (SYM...) FORM)" @@ -2002,7 +2002,7 @@ (cons 'progn body)) ;;;###autoload (defmacro cl-the (_type form) - "At present this ignores _TYPE and is simply equivalent to FORM." + "At present this ignores TYPE and is simply equivalent to FORM." (declare (indent 1) (debug (cl-type-spec form))) form) @@ -2059,7 +2059,7 @@ "Declare SPECS about the current function while compiling. For instance - \(cl-declare (warn 0)) + (cl-declare (warn 0)) will turn off byte-compile warnings in the function. See Info node `(cl)Declarations' for details." @@ -2279,8 +2279,8 @@ Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where SDEFAULT is the default value of that slot and SOPTIONS are keyword-value pairs for that slot. -Currently, only one keyword is supported, `:read-only'. If this has a non-nil -value, that slot cannot be set via `setf'. +Currently, only one keyword is supported, `:read-only'. If this has a +non-nil value, that slot cannot be set via `setf'. \(fn NAME SLOTS...)" (declare (doc-string 2) (indent 1) ------------------------------------------------------------ revno: 113382 fixes bug: http://debbugs.gnu.org/11954 committer: Leo Liu branch nick: trunk timestamp: Fri 2013-07-12 09:01:53 +0800 message: * ido.el (dired-do-copy, dired): Set 'ido property. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-11 17:16:19 +0000 +++ lisp/ChangeLog 2013-07-12 01:01:53 +0000 @@ -1,3 +1,7 @@ +2013-07-12 Leo Liu + + * ido.el (dired-do-copy, dired): Set 'ido property. (Bug#11954) + 2013-07-11 Glenn Morris * emacs-lisp/edebug.el: Require cl-lib at run-time too. === modified file 'lisp/ido.el' --- lisp/ido.el 2013-07-11 02:59:54 +0000 +++ lisp/ido.el 2013-07-12 01:01:53 +0000 @@ -4727,9 +4727,12 @@ ;;; Helper functions for other programs -(put 'dired-do-rename 'ido 'ignore) (put 'ibuffer-find-file 'ido 'find-file) +(put 'dired 'ido 'dir) (put 'dired-other-window 'ido 'dir) +;; See http://debbugs.gnu.org/11954 for reasons. +(put 'dired-do-copy 'ido 'ignore) +(put 'dired-do-rename 'ido 'ignore) ;;;###autoload (defun ido-read-buffer (prompt &optional default require-match) ------------------------------------------------------------ revno: 113381 author: Paul Eggert committer: Paul Eggert branch nick: trunk timestamp: Thu 2013-07-11 10:28:58 -0700 message: * inotify.c (uninitialized): Remove. All uses replaced by -1. (Finotify_add_watch): Simplify, since -1 means uninitialized now. Touch up doc a bit. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-11 07:17:23 +0000 +++ src/ChangeLog 2013-07-11 17:28:58 +0000 @@ -1,5 +1,9 @@ 2013-07-11 Paul Eggert + * inotify.c (uninitialized): Remove. All uses replaced by -1. + (Finotify_add_watch): Simplify, since -1 means uninitialized now. + Touch up doc a bit. + * eval.c (backtrace_function, backtrace_args): Now EXTERNALLY_VISIBLE. This is for .gdbinit xbacktrace. === modified file 'src/inotify.c' --- src/inotify.c 2013-07-04 09:29:28 +0000 +++ src/inotify.c 2013-07-11 17:28:58 +0000 @@ -71,9 +71,8 @@ # define IN_ONLYDIR 0 #endif -enum { uninitialized = -100 }; /* File handle for inotify. */ -static int inotifyfd = uninitialized; +static int inotifyfd = -1; /* Assoc list of files being watched. Format: @@ -268,8 +267,10 @@ DEFUN ("inotify-add-watch", Finotify_add_watch, Sinotify_add_watch, 3, 3, 0, doc: /* Add a watch for FILE-NAME to inotify. -A WATCH-DESCRIPTOR is returned on success. ASPECT might be one of the following -symbols or a list of those symbols: +Return a watch descriptor. The watch will look for ASPECT events and +invoke CALLBACK when an event occurs. + +ASPECT might be one of the following symbols or a list of those symbols: access attrib @@ -288,7 +289,7 @@ move close -The following symbols can also be added to a list of aspects +The following symbols can also be added to a list of aspects: dont-follow excl-unlink @@ -296,9 +297,8 @@ oneshot onlydir -Watching a directory is not recursive. CALLBACK gets called in case of an -event. It gets passed a single argument EVENT which contains an event structure -of the format +Watching a directory is not recursive. CALLBACK is passed a single argument +EVENT which contains an event structure of the format (WATCH-DESCRIPTOR ASPECTS NAME COOKIE) @@ -331,16 +331,13 @@ CHECK_STRING (file_name); - if (inotifyfd == uninitialized) + if (inotifyfd < 0) { inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC); - if (inotifyfd == -1) - { - inotifyfd = uninitialized; - xsignal1 - (Qfile_notify_error, - build_string ("File watching feature (inotify) is not available")); - } + if (inotifyfd < 0) + xsignal1 + (Qfile_notify_error, + build_string ("File watching feature (inotify) is not available")); watch_list = Qnil; add_read_fd (inotifyfd, &inotify_callback, NULL); } @@ -392,7 +389,7 @@ { close (inotifyfd); delete_read_fd (inotifyfd); - inotifyfd = uninitialized; + inotifyfd = -1; } return Qt; ------------------------------------------------------------ revno: 113380 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 13:27:27 -0400 message: ChangeLog fix diff: === modified file 'etc/ChangeLog' --- etc/ChangeLog 2013-07-10 06:26:23 +0000 +++ etc/ChangeLog 2013-07-11 17:27:27 +0000 @@ -5,7 +5,7 @@ 2013-07-08 Jan Djärv - * NEWS: NS can be build with ImageMagick. + * NEWS: NS can be built with ImageMagick. 2013-07-06 Juanma Barranquero ------------------------------------------------------------ revno: 113379 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 13:18:48 -0400 message: ChangeLog fixes diff: === modified file 'ChangeLog' --- ChangeLog 2013-07-10 06:41:37 +0000 +++ ChangeLog 2013-07-11 17:18:48 +0000 @@ -81,7 +81,7 @@ * Makefile.in (install-arch-indep): Do not create directories passed with --enable-locallisppath. -2013-06-24 Glenn Morris +2013-06-24 Glenn Morris * configure.ac: Include X11/X.h when testing for Xft.h. (Bug#14684) === modified file 'lisp/cedet/ChangeLog' --- lisp/cedet/ChangeLog 2013-06-25 16:13:49 +0000 +++ lisp/cedet/ChangeLog 2013-07-11 17:18:48 +0000 @@ -2,7 +2,7 @@ * data-debug.el, cedet-idutils.el: Neuter the "Version:" header. -2013-06-19 Glenn Morris +2013-06-19 Glenn Morris * semantic/idle.el (define-semantic-idle-service): No need to use eval-and-compile, progn will do. === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-11 16:13:38 +0000 +++ test/ChangeLog 2013-07-11 17:18:48 +0000 @@ -136,7 +136,7 @@ Use it to create separate tests for each element, so we run them all rather than stopping at the first error. -2013-06-24 Glenn Morris +2013-06-24 Glenn Morris * automated/occur-tests.el (occur-tests): Update for 2013-05-29 change to occur header line. ------------------------------------------------------------ revno: 113378 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 13:16:19 -0400 message: Remove some reimplementations of cl-gensym * lisp/thumbs.el: Require cl-lib at run-time too. (thumbs-gensym-counter, thumbs-gensym): Remove reimplementation of cl-gensym. (thumbs-temp-file): Use cl-gensym. * lisp/emacs-lisp/edebug.el: Require cl-lib at run-time too. (edebug-gensym-index, edebug-gensym): Remove reimplementation of cl-gensym. (edebug-make-enter-wrapper, edebug-make-form-wrapper): Use cl-gensym. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-11 16:13:38 +0000 +++ lisp/ChangeLog 2013-07-11 17:16:19 +0000 @@ -1,5 +1,15 @@ 2013-07-11 Glenn Morris + * emacs-lisp/edebug.el: Require cl-lib at run-time too. + (edebug-gensym-index, edebug-gensym): + Remove reimplementation of cl-gensym. + (edebug-make-enter-wrapper, edebug-make-form-wrapper): Use cl-gensym. + + * thumbs.el: Require cl-lib at run-time too. + (thumbs-gensym-counter, thumbs-gensym): + Remove reimplementation of cl-gensym. + (thumbs-temp-file): Use cl-gensym. + * emacs-lisp/ert.el: Require cl-lib at runtime too. (ert--cl-do-remf, ert--remprop, ert--remove-if-not) (ert--intersection, ert--set-difference, ert--set-difference-eq) @@ -691,7 +701,7 @@ * emacs-lock.el (emacs-lock-mode, emacs-lock--old-mode) (emacs-lock--try-unlocking): Make defvar-local. -2013-06-22 Glenn Morris +2013-06-22 Glenn Morris * play/cookie1.el (cookie-apropos): Minor simplification. @@ -1157,7 +1167,7 @@ * net/shr.el (shr-map): Bind [down-mouse-1] to browse URLs. -2013-06-19 Glenn Morris +2013-06-19 Glenn Morris * emacs-lisp/eieio.el (defclass): Make it eval-and-compile once more. === modified file 'lisp/emacs-lisp/edebug.el' --- lisp/emacs-lisp/edebug.el 2013-06-05 14:57:45 +0000 +++ lisp/emacs-lisp/edebug.el 2013-07-11 17:16:19 +0000 @@ -53,7 +53,7 @@ ;;; Code: (require 'macroexp) -(eval-when-compile (require 'cl-lib)) +(require 'cl-lib) (eval-when-compile (require 'pcase)) ;;; Options @@ -263,26 +263,6 @@ ;;; Utilities -;; Define edebug-gensym - from old cl.el -(defvar edebug-gensym-index 0 - "Integer used by `edebug-gensym' to produce new names.") - -(defun edebug-gensym (&optional prefix) - "Generate a fresh uninterned symbol. -There is an optional argument, PREFIX. PREFIX is the string -that begins the new name. Most people take just the default, -except when debugging needs suggest otherwise." - (if (null prefix) - (setq prefix "G")) - (let ((newsymbol nil) - (newname "")) - (while (not newsymbol) - (setq newname (concat prefix (int-to-string edebug-gensym-index))) - (setq edebug-gensym-index (+ edebug-gensym-index 1)) - (if (not (intern-soft newname)) - (setq newsymbol (make-symbol newname)))) - newsymbol)) - (defun edebug-lambda-list-keywordp (object) "Return t if OBJECT is a lambda list keyword. A lambda list keyword is a symbol that starts with `&'." @@ -1186,7 +1166,7 @@ ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args. ;; Do this after parsing since that may find a name. (setq edebug-def-name - (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) + (or edebug-def-name edebug-old-def-name (cl-gensym "edebug-anon"))) `(edebug-enter (quote ,edebug-def-name) ,(if edebug-inside-func @@ -1299,7 +1279,7 @@ ;; Set the name here if it was not set by edebug-make-enter-wrapper. (setq edebug-def-name - (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) + (or edebug-def-name edebug-old-def-name (cl-gensym "edebug-anon"))) ;; Add this def as a dependent of containing def. Buggy. '(if (and edebug-containing-def-name === modified file 'lisp/thumbs.el' --- lisp/thumbs.el 2013-01-01 09:11:05 +0000 +++ lisp/thumbs.el 2013-07-11 17:16:19 +0000 @@ -57,6 +57,7 @@ ;;; Code: (require 'dired) +(require 'cl-lib) ; for cl-gensym ;; CUSTOMIZATIONS @@ -179,21 +180,6 @@ (make-variable-buffer-local 'thumbs-marked-list) (put 'thumbs-marked-list 'permanent-local t) -(defalias 'thumbs-gensym - (if (fboundp 'gensym) - 'gensym - ;; Copied from cl-macs.el - (defvar thumbs-gensym-counter 0) - (lambda (&optional prefix) - "Generate a new uninterned symbol. -The name is made by appending a number to PREFIX, default \"G\"." - (let ((pfix (if (stringp prefix) prefix "G")) - (num (if (integerp prefix) prefix - (prog1 thumbs-gensym-counter - (setq thumbs-gensym-counter - (1+ thumbs-gensym-counter)))))) - (make-symbol (format "%s%d" pfix num)))))) - (defsubst thumbs-temp-dir () (file-name-as-directory (expand-file-name thumbs-temp-dir))) @@ -202,7 +188,7 @@ (format "%s%s-%s.jpg" (thumbs-temp-dir) thumbs-temp-prefix - (thumbs-gensym "T"))) + (cl-gensym "T"))) (defun thumbs-thumbsdir () "Return the current thumbnails directory (from `thumbs-thumbsdir'). ------------------------------------------------------------ revno: 113377 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 09:15:57 -0700 message: * admin/notes/changelogs: Explain "there is no need". diff: === modified file 'admin/notes/changelogs' --- admin/notes/changelogs 2013-06-15 13:21:17 +0000 +++ admin/notes/changelogs 2013-07-11 16:15:57 +0000 @@ -3,9 +3,10 @@ http://lists.gnu.org/archive/html/emacs-devel/2007-09/msg00793.html -http://lists.gnu.org/archive/html/emacs-devel/2013-06/msg00485.html - There is no need to make trivial change log entries for files such - as NEWS, MAINTAINERS, and FOR-RELEASE. + There is no need to make change log entries for files such as NEWS, + MAINTAINERS, and FOR-RELEASE. +"There is no need" means you don't have to, but you can if you want to. + http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01135.html There is no need to indicate regeneration of files such as configure ------------------------------------------------------------ revno: 113376 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 09:13:38 -0700 message: Stop reimplementing a bunch of cl- functions in ert * lisp/emacs-lisp/ert.el: Require cl-lib at runtime too. (ert--cl-do-remf, ert--remprop, ert--remove-if-not) (ert--intersection, ert--set-difference, ert--set-difference-eq) (ert--union, ert--gensym-counter, ert--gensym-counter) (ert--coerce-to-vector, ert--remove*, ert--string-position) (ert--mismatch, ert--subseq): Remove reimplementations of cl funcs. (ert-make-test-unbound, ert--expand-should-1) (ert--expand-should, ert--should-error-handle-error) (should-error, ert--explain-equal-rec) (ert--plist-difference-explanation, ert-select-tests) (ert--make-stats, ert--remove-from-list, ert--string-first-line): Use cl-lib functions rather than reimplementations. * test/automated/ert-tests.el: Require cl-lib at runtime too. (ert-test-special-operator-p): Use cl-gensym rather than ert-- version. (ert-test-remprop, ert-test-remove-if-not, ert-test-remove*) (ert-test-set-functions, ert-test-gensym) (ert-test-coerce-to-vector, ert-test-string-position) (ert-test-mismatch): Remove tests. * test/automated/cl-lib.el: New, split from ert-tests.el. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-11 09:52:54 +0000 +++ lisp/ChangeLog 2013-07-11 16:13:38 +0000 @@ -1,3 +1,18 @@ +2013-07-11 Glenn Morris + + * emacs-lisp/ert.el: Require cl-lib at runtime too. + (ert--cl-do-remf, ert--remprop, ert--remove-if-not) + (ert--intersection, ert--set-difference, ert--set-difference-eq) + (ert--union, ert--gensym-counter, ert--gensym-counter) + (ert--coerce-to-vector, ert--remove*, ert--string-position) + (ert--mismatch, ert--subseq): Remove reimplementations of cl funcs. + (ert-make-test-unbound, ert--expand-should-1) + (ert--expand-should, ert--should-error-handle-error) + (should-error, ert--explain-equal-rec) + (ert--plist-difference-explanation, ert-select-tests) + (ert--make-stats, ert--remove-from-list, ert--string-first-line): + Use cl-lib functions rather than reimplementations. + 2013-07-11 Michael Albinus * net/tramp.el (tramp-methods): Extend docstring. === modified file 'lisp/emacs-lisp/ert.el' --- lisp/emacs-lisp/ert.el 2013-04-07 20:42:11 +0000 +++ lisp/emacs-lisp/ert.el 2013-07-11 16:13:38 +0000 @@ -54,7 +54,7 @@ ;;; Code: -(eval-when-compile (require 'cl-lib)) +(require 'cl-lib) (require 'button) (require 'debug) (require 'easymenu) @@ -87,127 +87,6 @@ ;;; Copies/reimplementations of cl functions. -(defun ert--cl-do-remf (plist tag) - "Copy of `cl-do-remf'. Modify PLIST by removing TAG." - (let ((p (cdr plist))) - (while (and (cdr p) (not (eq (car (cdr p)) tag))) (setq p (cdr (cdr p)))) - (and (cdr p) (progn (setcdr p (cdr (cdr (cdr p)))) t)))) - -(defun ert--remprop (sym tag) - "Copy of `cl-remprop'. Modify SYM's plist by removing TAG." - (let ((plist (symbol-plist sym))) - (if (and plist (eq tag (car plist))) - (progn (setplist sym (cdr (cdr plist))) t) - (ert--cl-do-remf plist tag)))) - -(defun ert--remove-if-not (ert-pred ert-list) - "A reimplementation of `remove-if-not'. - -ERT-PRED is a predicate, ERT-LIST is the input list." - (cl-loop for ert-x in ert-list - if (funcall ert-pred ert-x) - collect ert-x)) - -(defun ert--intersection (a b) - "A reimplementation of `intersection'. Intersect the sets A and B. - -Elements are compared using `eql'." - (cl-loop for x in a - if (memql x b) - collect x)) - -(defun ert--set-difference (a b) - "A reimplementation of `set-difference'. Subtract the set B from the set A. - -Elements are compared using `eql'." - (cl-loop for x in a - unless (memql x b) - collect x)) - -(defun ert--set-difference-eq (a b) - "A reimplementation of `set-difference'. Subtract the set B from the set A. - -Elements are compared using `eq'." - (cl-loop for x in a - unless (memq x b) - collect x)) - -(defun ert--union (a b) - "A reimplementation of `union'. Compute the union of the sets A and B. - -Elements are compared using `eql'." - (append a (ert--set-difference b a))) - -(eval-and-compile - (defvar ert--gensym-counter 0)) - -(eval-and-compile - (defun ert--gensym (&optional prefix) - "Only allows string PREFIX, not compatible with CL." - (unless prefix (setq prefix "G")) - (make-symbol (format "%s%s" - prefix - (prog1 ert--gensym-counter - (cl-incf ert--gensym-counter)))))) - -(defun ert--coerce-to-vector (x) - "Coerce X to a vector." - (when (char-table-p x) (error "Not supported")) - (if (vectorp x) - x - (vconcat x))) - -(cl-defun ert--remove* (x list &key key test) - "Does not support all the keywords of remove*." - (unless key (setq key #'identity)) - (unless test (setq test #'eql)) - (cl-loop for y in list - unless (funcall test x (funcall key y)) - collect y)) - -(defun ert--string-position (c s) - "Return the position of the first occurrence of C in S, or nil if none." - (cl-loop for i from 0 - for x across s - when (eql x c) return i)) - -(defun ert--mismatch (a b) - "Return index of first element that differs between A and B. - -Like `mismatch'. Uses `equal' for comparison." - (cond ((or (listp a) (listp b)) - (ert--mismatch (ert--coerce-to-vector a) - (ert--coerce-to-vector b))) - ((> (length a) (length b)) - (ert--mismatch b a)) - (t - (let ((la (length a)) - (lb (length b))) - (cl-assert (arrayp a) t) - (cl-assert (arrayp b) t) - (cl-assert (<= la lb) t) - (cl-loop for i below la - when (not (equal (aref a i) (aref b i))) return i - finally (cl-return (if (/= la lb) - la - (cl-assert (equal a b) t) - nil))))))) - -(defun ert--subseq (seq start &optional end) - "Return a subsequence of SEQ from START to END." - (when (char-table-p seq) (error "Not supported")) - (let ((vector (substring (ert--coerce-to-vector seq) start end))) - (cl-etypecase seq - (vector vector) - (string (concat vector)) - (list (append vector nil)) - (bool-vector (cl-loop with result - = (make-bool-vector (length vector) nil) - for i below (length vector) do - (setf (aref result i) (aref vector i)) - finally (cl-return result))) - (char-table (cl-assert nil))))) - (defun ert-equal-including-properties (a b) "Return t if A and B have similar structure and contents. @@ -258,7 +137,7 @@ (defun ert-make-test-unbound (symbol) "Make SYMBOL name no test. Return SYMBOL." - (ert--remprop symbol 'ert--test) + (cl-remprop symbol 'ert--test) symbol) (defun ert--parse-keys-and-body (keys-and-body) @@ -396,8 +275,8 @@ cl-macro-environment))))) (cond ((or (atom form) (ert--special-operator-p (car form))) - (let ((value (ert--gensym "value-"))) - `(let ((,value (ert--gensym "ert-form-evaluation-aborted-"))) + (let ((value (cl-gensym "value-"))) + `(let ((,value (cl-gensym "ert-form-evaluation-aborted-"))) ,(funcall inner-expander `(setq ,value ,form) `(list ',whole :form ',form :value ,value) @@ -410,10 +289,10 @@ (and (consp fn-name) (eql (car fn-name) 'lambda) (listp (cdr fn-name))))) - (let ((fn (ert--gensym "fn-")) - (args (ert--gensym "args-")) - (value (ert--gensym "value-")) - (default-value (ert--gensym "ert-form-evaluation-aborted-"))) + (let ((fn (cl-gensym "fn-")) + (args (cl-gensym "args-")) + (value (cl-gensym "value-")) + (default-value (cl-gensym "ert-form-evaluation-aborted-"))) `(let ((,fn (function ,fn-name)) (,args (list ,@arg-forms))) (let ((,value ',default-value)) @@ -450,7 +329,7 @@ (ert--expand-should-1 whole form (lambda (inner-form form-description-form value-var) - (let ((form-description (ert--gensym "form-description-"))) + (let ((form-description (cl-gensym "form-description-"))) `(let (,form-description) ,(funcall inner-expander `(unwind-protect @@ -491,7 +370,7 @@ (list type) (symbol (list type))))) (cl-assert signaled-conditions) - (unless (ert--intersection signaled-conditions handled-conditions) + (unless (cl-intersection signaled-conditions handled-conditions) (ert-fail (append (funcall form-description-fn) (list @@ -528,8 +407,8 @@ `(should-error ,form ,@keys) form (lambda (inner-form form-description-form value-var) - (let ((errorp (ert--gensym "errorp")) - (form-description-fn (ert--gensym "form-description-fn-"))) + (let ((errorp (cl-gensym "errorp")) + (form-description-fn (cl-gensym "form-description-fn-"))) `(let ((,errorp nil) (,form-description-fn (lambda () ,form-description-form))) (condition-case -condition- @@ -591,7 +470,7 @@ `(proper-lists-of-different-length ,(length a) ,(length b) ,a ,b first-mismatch-at - ,(ert--mismatch a b)) + ,(cl-mismatch a b :test 'equal)) (cl-loop for i from 0 for ai in a for bi in b @@ -611,7 +490,7 @@ ,a ,b ,@(unless (char-table-p a) `(first-mismatch-at - ,(ert--mismatch a b)))) + ,(cl-mismatch a b :test 'equal)))) (cl-loop for i from 0 for ai across a for bi across b @@ -656,8 +535,8 @@ ;; work, so let's punt on it for now. (let* ((keys-a (ert--significant-plist-keys a)) (keys-b (ert--significant-plist-keys b)) - (keys-in-a-not-in-b (ert--set-difference-eq keys-a keys-b)) - (keys-in-b-not-in-a (ert--set-difference-eq keys-b keys-a))) + (keys-in-a-not-in-b (cl-set-difference keys-a keys-b :test 'eq)) + (keys-in-b-not-in-a (cl-set-difference keys-b keys-a :test 'eq))) (cl-flet ((explain-with-key (key) (let ((value-a (plist-get a key)) (value-b (plist-get b key))) @@ -1090,7 +969,7 @@ (cl-etypecase universe ((member t) (mapcar #'ert-get-test (apropos-internal selector #'ert-test-boundp))) - (list (ert--remove-if-not (lambda (test) + (list (cl-remove-if-not (lambda (test) (and (ert-test-name test) (string-match selector (ert-test-name test)))) @@ -1123,13 +1002,13 @@ (not (cl-assert (eql (length operands) 1)) (let ((all-tests (ert-select-tests 't universe))) - (ert--set-difference all-tests + (cl-set-difference all-tests (ert-select-tests (car operands) all-tests)))) (or (cl-case (length operands) (0 (ert-select-tests 'nil universe)) - (t (ert--union (ert-select-tests (car operands) universe) + (t (cl-union (ert-select-tests (car operands) universe) (ert-select-tests `(or ,@(cdr operands)) universe))))) (tag @@ -1141,7 +1020,7 @@ universe))) (satisfies (cl-assert (eql (length operands) 1)) - (ert--remove-if-not (car operands) + (cl-remove-if-not (car operands) (ert-select-tests 't universe)))))))) (defun ert--insert-human-readable-selector (selector) @@ -1285,7 +1164,7 @@ "Create a new `ert--stats' object for running TESTS. SELECTOR is the selector that was used to select TESTS." - (setq tests (ert--coerce-to-vector tests)) + (setq tests (cl-coerce tests 'vector)) (let ((map (make-hash-table :size (length tests)))) (cl-loop for i from 0 for test across tests @@ -1548,10 +1427,10 @@ (unless key (setq key #'identity)) (unless test (setq test #'equal)) (setf (symbol-value list-var) - (ert--remove* element - (symbol-value list-var) - :key key - :test test))) + (cl-remove element + (symbol-value list-var) + :key key + :test test))) ;;; Some basic interactive functions. @@ -1810,7 +1689,7 @@ "Return the first line of S, or S if it contains no newlines. The return value does not include the line terminator." - (substring s 0 (ert--string-position ?\n s))) + (substring s 0 (cl-position ?\n s))) (defun ert-face-for-test-result (expectedp) "Return a face that shows whether a test result was expected or unexpected. === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-11 16:04:56 +0000 +++ test/ChangeLog 2013-07-11 16:13:38 +0000 @@ -1,5 +1,13 @@ 2013-07-11 Glenn Morris + * automated/ert-tests.el: Require cl-lib at runtime too. + (ert-test-special-operator-p): Use cl-gensym rather than ert-- version. + (ert-test-remprop, ert-test-remove-if-not, ert-test-remove*) + (ert-test-set-functions, ert-test-gensym) + (ert-test-coerce-to-vector, ert-test-string-position) + (ert-test-mismatch): Remove tests. + * automated/cl-lib.el: New, split from ert-tests.el. + * automated/ruby-mode-tests.el (ruby-deftest-move-to-block): Goto point-min. (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two) === added file 'test/automated/cl-lib.el' --- test/automated/cl-lib.el 1970-01-01 00:00:00 +0000 +++ test/automated/cl-lib.el 2013-07-11 16:13:38 +0000 @@ -0,0 +1,198 @@ +;;; cl-lib.el --- tests for emacs-lisp/cl-lib.el + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; This program is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation, either version 3 of the +;; License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see `http://www.gnu.org/licenses/'. + +;;; Commentary: + +;; Extracted from ert-tests.el, back when ert used to reimplement some +;; cl functions. + +;;; Code: + +(require 'cl-lib) +(require 'ert) + +(ert-deftest cl-lib-test-remprop () + (let ((x (cl-gensym))) + (should (equal (symbol-plist x) '())) + ;; Remove nonexistent property on empty plist. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '())) + (put x 'a 1) + (should (equal (symbol-plist x) '(a 1))) + ;; Remove nonexistent property on nonempty plist. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '(a 1))) + (put x 'b 2) + (put x 'c 3) + (put x 'd 4) + (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) + ;; Remove property that is neither first nor last. + (cl-remprop x 'c) + (should (equal (symbol-plist x) '(a 1 b 2 d 4))) + ;; Remove last property from a plist of length >1. + (cl-remprop x 'd) + (should (equal (symbol-plist x) '(a 1 b 2))) + ;; Remove first property from a plist of length >1. + (cl-remprop x 'a) + (should (equal (symbol-plist x) '(b 2))) + ;; Remove property when there is only one. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '())))) + +(ert-deftest cl-lib-test-remove-if-not () + (let ((list (list 'a 'b 'c 'd)) + (i 0)) + (let ((result (cl-remove-if-not (lambda (x) + (should (eql x (nth i list))) + (cl-incf i) + (member i '(2 3))) + list))) + (should (equal i 4)) + (should (equal result '(b c))) + (should (equal list '(a b c d))))) + (should (equal '() + (cl-remove-if-not (lambda (_x) (should nil)) '())))) + +(ert-deftest cl-lib-test-remove () + (let ((list (list 'a 'b 'c 'd)) + (key-index 0) + (test-index 0)) + (let ((result + (cl-remove 'foo list + :key (lambda (x) + (should (eql x (nth key-index list))) + (prog1 + (list key-index x) + (cl-incf key-index))) + :test + (lambda (a b) + (should (eql a 'foo)) + (should (equal b (list test-index + (nth test-index list)))) + (cl-incf test-index) + (member test-index '(2 3)))))) + (should (equal key-index 4)) + (should (equal test-index 4)) + (should (equal result '(a d))) + (should (equal list '(a b c d))))) + (let ((x (cons nil nil)) + (y (cons nil nil))) + (should (equal (cl-remove x (list x y)) + ;; or (list x), since we use `equal' -- the + ;; important thing is that only one element got + ;; removed, this proves that the default test is + ;; `eql', not `equal' + (list y))))) + + +(ert-deftest cl-lib-test-set-functions () + (let ((c1 (cons nil nil)) + (c2 (cons nil nil)) + (sym (make-symbol "a"))) + (let ((e '()) + (a (list 'a 'b sym nil "" "x" c1 c2)) + (b (list c1 'y 'b sym 'x))) + (should (equal (cl-set-difference e e) e)) + (should (equal (cl-set-difference a e) a)) + (should (equal (cl-set-difference e a) e)) + (should (equal (cl-set-difference a a) e)) + (should (equal (cl-set-difference b e) b)) + (should (equal (cl-set-difference e b) e)) + (should (equal (cl-set-difference b b) e)) + ;; Note: this test (and others) is sensitive to the order of the + ;; result, which is not documented. + (should (equal (cl-set-difference a b) (list c2 "x" "" nil 'a))) + (should (equal (cl-set-difference b a) (list 'x 'y))) + + ;; We aren't testing whether this is really using `eq' rather than `eql'. + (should (equal (cl-set-difference e e :test 'eq) e)) + (should (equal (cl-set-difference a e :test 'eq) a)) + (should (equal (cl-set-difference e a :test 'eq) e)) + (should (equal (cl-set-difference a a :test 'eq) e)) + (should (equal (cl-set-difference b e :test 'eq) b)) + (should (equal (cl-set-difference e b :test 'eq) e)) + (should (equal (cl-set-difference b b :test 'eq) e)) + (should (equal (cl-set-difference a b :test 'eq) (list c2 "x" "" nil 'a))) + (should (equal (cl-set-difference b a :test 'eq) (list 'x 'y))) + + (should (equal (cl-union e e) e)) + (should (equal (cl-union a e) a)) + (should (equal (cl-union e a) a)) + (should (equal (cl-union a a) a)) + (should (equal (cl-union b e) b)) + (should (equal (cl-union e b) b)) + (should (equal (cl-union b b) b)) + (should (equal (cl-union a b) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) + + (should (equal (cl-union b a) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) + + (should (equal (cl-intersection e e) e)) + (should (equal (cl-intersection a e) e)) + (should (equal (cl-intersection e a) e)) + (should (equal (cl-intersection a a) a)) + (should (equal (cl-intersection b e) e)) + (should (equal (cl-intersection e b) e)) + (should (equal (cl-intersection b b) b)) + (should (equal (cl-intersection a b) (list sym 'b c1))) + (should (equal (cl-intersection b a) (list sym 'b c1)))))) + +(ert-deftest cl-lib-test-gensym () + ;; Since the expansion of `should' calls `cl-gensym' and thus has a + ;; side-effect on `cl--gensym-counter', we have to make sure all + ;; macros in our test body are expanded before we rebind + ;; `cl--gensym-counter' and run the body. Otherwise, the test would + ;; fail if run interpreted. + (let ((body (byte-compile + '(lambda () + (should (equal (symbol-name (cl-gensym)) "G0")) + (should (equal (symbol-name (cl-gensym)) "G1")) + (should (equal (symbol-name (cl-gensym)) "G2")) + (should (equal (symbol-name (cl-gensym "foo")) "foo3")) + (should (equal (symbol-name (cl-gensym "bar")) "bar4")) + (should (equal cl--gensym-counter 5)))))) + (let ((cl--gensym-counter 0)) + (funcall body)))) + +(ert-deftest cl-lib-test-coerce-to-vector () + (let* ((a (vector)) + (b (vector 1 a 3)) + (c (list)) + (d (list b a))) + (should (eql (cl-coerce a 'vector) a)) + (should (eql (cl-coerce b 'vector) b)) + (should (equal (cl-coerce c 'vector) (vector))) + (should (equal (cl-coerce d 'vector) (vector b a))))) + +(ert-deftest cl-lib-test-string-position () + (should (eql (cl-position ?x "") nil)) + (should (eql (cl-position ?a "abc") 0)) + (should (eql (cl-position ?b "abc") 1)) + (should (eql (cl-position ?c "abc") 2)) + (should (eql (cl-position ?d "abc") nil)) + (should (eql (cl-position ?A "abc") nil))) + +(ert-deftest cl-lib-test-mismatch () + (should (eql (cl-mismatch "" "") nil)) + (should (eql (cl-mismatch "" "a") 0)) + (should (eql (cl-mismatch "a" "a") nil)) + (should (eql (cl-mismatch "ab" "a") 1)) + (should (eql (cl-mismatch "Aa" "aA") 0)) + (should (eql (cl-mismatch '(a b c) '(a b d)) 2))) + +;;; cl-lib.el ends here === modified file 'test/automated/ert-tests.el' --- test/automated/ert-tests.el 2013-01-02 16:13:04 +0000 +++ test/automated/ert-tests.el 2013-07-11 16:13:38 +0000 @@ -26,11 +26,9 @@ ;;; Code: -(eval-when-compile - (require 'cl-lib)) +(require 'cl-lib) (require 'ert) - ;;; Self-test that doesn't rely on ERT, for bootstrapping. ;; This is used to test that bodies actually run. @@ -578,7 +576,7 @@ (should (ert--special-operator-p 'if)) (should-not (ert--special-operator-p 'car)) (should-not (ert--special-operator-p 'ert--special-operator-p)) - (let ((b (ert--gensym))) + (let ((b (cl-gensym))) (should-not (ert--special-operator-p b)) (fset b 'if) (should (ert--special-operator-p b)))) @@ -626,171 +624,6 @@ :explanation nil) )))))) -(ert-deftest ert-test-remprop () - (let ((x (ert--gensym))) - (should (equal (symbol-plist x) '())) - ;; Remove nonexistent property on empty plist. - (ert--remprop x 'b) - (should (equal (symbol-plist x) '())) - (put x 'a 1) - (should (equal (symbol-plist x) '(a 1))) - ;; Remove nonexistent property on nonempty plist. - (ert--remprop x 'b) - (should (equal (symbol-plist x) '(a 1))) - (put x 'b 2) - (put x 'c 3) - (put x 'd 4) - (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) - ;; Remove property that is neither first nor last. - (ert--remprop x 'c) - (should (equal (symbol-plist x) '(a 1 b 2 d 4))) - ;; Remove last property from a plist of length >1. - (ert--remprop x 'd) - (should (equal (symbol-plist x) '(a 1 b 2))) - ;; Remove first property from a plist of length >1. - (ert--remprop x 'a) - (should (equal (symbol-plist x) '(b 2))) - ;; Remove property when there is only one. - (ert--remprop x 'b) - (should (equal (symbol-plist x) '())))) - -(ert-deftest ert-test-remove-if-not () - (let ((list (list 'a 'b 'c 'd)) - (i 0)) - (let ((result (ert--remove-if-not (lambda (x) - (should (eql x (nth i list))) - (cl-incf i) - (member i '(2 3))) - list))) - (should (equal i 4)) - (should (equal result '(b c))) - (should (equal list '(a b c d))))) - (should (equal '() - (ert--remove-if-not (lambda (_x) (should nil)) '())))) - -(ert-deftest ert-test-remove* () - (let ((list (list 'a 'b 'c 'd)) - (key-index 0) - (test-index 0)) - (let ((result - (ert--remove* 'foo list - :key (lambda (x) - (should (eql x (nth key-index list))) - (prog1 - (list key-index x) - (cl-incf key-index))) - :test - (lambda (a b) - (should (eql a 'foo)) - (should (equal b (list test-index - (nth test-index list)))) - (cl-incf test-index) - (member test-index '(2 3)))))) - (should (equal key-index 4)) - (should (equal test-index 4)) - (should (equal result '(a d))) - (should (equal list '(a b c d))))) - (let ((x (cons nil nil)) - (y (cons nil nil))) - (should (equal (ert--remove* x (list x y)) - ;; or (list x), since we use `equal' -- the - ;; important thing is that only one element got - ;; removed, this proves that the default test is - ;; `eql', not `equal' - (list y))))) - - -(ert-deftest ert-test-set-functions () - (let ((c1 (cons nil nil)) - (c2 (cons nil nil)) - (sym (make-symbol "a"))) - (let ((e '()) - (a (list 'a 'b sym nil "" "x" c1 c2)) - (b (list c1 'y 'b sym 'x))) - (should (equal (ert--set-difference e e) e)) - (should (equal (ert--set-difference a e) a)) - (should (equal (ert--set-difference e a) e)) - (should (equal (ert--set-difference a a) e)) - (should (equal (ert--set-difference b e) b)) - (should (equal (ert--set-difference e b) e)) - (should (equal (ert--set-difference b b) e)) - (should (equal (ert--set-difference a b) (list 'a nil "" "x" c2))) - (should (equal (ert--set-difference b a) (list 'y 'x))) - - ;; We aren't testing whether this is really using `eq' rather than `eql'. - (should (equal (ert--set-difference-eq e e) e)) - (should (equal (ert--set-difference-eq a e) a)) - (should (equal (ert--set-difference-eq e a) e)) - (should (equal (ert--set-difference-eq a a) e)) - (should (equal (ert--set-difference-eq b e) b)) - (should (equal (ert--set-difference-eq e b) e)) - (should (equal (ert--set-difference-eq b b) e)) - (should (equal (ert--set-difference-eq a b) (list 'a nil "" "x" c2))) - (should (equal (ert--set-difference-eq b a) (list 'y 'x))) - - (should (equal (ert--union e e) e)) - (should (equal (ert--union a e) a)) - (should (equal (ert--union e a) a)) - (should (equal (ert--union a a) a)) - (should (equal (ert--union b e) b)) - (should (equal (ert--union e b) b)) - (should (equal (ert--union b b) b)) - (should (equal (ert--union a b) (list 'a 'b sym nil "" "x" c1 c2 'y 'x))) - (should (equal (ert--union b a) (list c1 'y 'b sym 'x 'a nil "" "x" c2))) - - (should (equal (ert--intersection e e) e)) - (should (equal (ert--intersection a e) e)) - (should (equal (ert--intersection e a) e)) - (should (equal (ert--intersection a a) a)) - (should (equal (ert--intersection b e) e)) - (should (equal (ert--intersection e b) e)) - (should (equal (ert--intersection b b) b)) - (should (equal (ert--intersection a b) (list 'b sym c1))) - (should (equal (ert--intersection b a) (list c1 'b sym)))))) - -(ert-deftest ert-test-gensym () - ;; Since the expansion of `should' calls `ert--gensym' and thus has a - ;; side-effect on `ert--gensym-counter', we have to make sure all - ;; macros in our test body are expanded before we rebind - ;; `ert--gensym-counter' and run the body. Otherwise, the test would - ;; fail if run interpreted. - (let ((body (byte-compile - '(lambda () - (should (equal (symbol-name (ert--gensym)) "G0")) - (should (equal (symbol-name (ert--gensym)) "G1")) - (should (equal (symbol-name (ert--gensym)) "G2")) - (should (equal (symbol-name (ert--gensym "foo")) "foo3")) - (should (equal (symbol-name (ert--gensym "bar")) "bar4")) - (should (equal ert--gensym-counter 5)))))) - (let ((ert--gensym-counter 0)) - (funcall body)))) - -(ert-deftest ert-test-coerce-to-vector () - (let* ((a (vector)) - (b (vector 1 a 3)) - (c (list)) - (d (list b a))) - (should (eql (ert--coerce-to-vector a) a)) - (should (eql (ert--coerce-to-vector b) b)) - (should (equal (ert--coerce-to-vector c) (vector))) - (should (equal (ert--coerce-to-vector d) (vector b a))))) - -(ert-deftest ert-test-string-position () - (should (eql (ert--string-position ?x "") nil)) - (should (eql (ert--string-position ?a "abc") 0)) - (should (eql (ert--string-position ?b "abc") 1)) - (should (eql (ert--string-position ?c "abc") 2)) - (should (eql (ert--string-position ?d "abc") nil)) - (should (eql (ert--string-position ?A "abc") nil))) - -(ert-deftest ert-test-mismatch () - (should (eql (ert--mismatch "" "") nil)) - (should (eql (ert--mismatch "" "a") 0)) - (should (eql (ert--mismatch "a" "a") nil)) - (should (eql (ert--mismatch "ab" "a") 1)) - (should (eql (ert--mismatch "Aa" "aA") 0)) - (should (eql (ert--mismatch '(a b c) '(a b d)) 2))) - (ert-deftest ert-test-string-first-line () (should (equal (ert--string-first-line "") "")) (should (equal (ert--string-first-line "abc") "abc")) ------------------------------------------------------------ revno: 113375 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 09:07:00 -0700 message: Adding :safe property to a defcustom does not merit a :version bump diff: === modified file 'lisp/files.el' --- lisp/files.el 2013-07-10 06:26:23 +0000 +++ lisp/files.el 2013-07-11 16:07:00 +0000 @@ -322,8 +322,7 @@ (const :tag "When visiting or saving" visit-save) (const :tag "Don't add newlines" nil) (other :tag "Ask each time" ask)) - :group 'editing-basics - :version "24.4") + :group 'editing-basics) (defcustom mode-require-final-newline t "Whether to add a newline at end of file, in certain major modes. ------------------------------------------------------------ revno: 113374 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 09:04:56 -0700 message: Quieten ruby-mode-tests.el compilation * test/automated/ruby-mode-tests.el (ruby-deftest-move-to-block): Goto point-min. (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two) (ruby-move-to-block-skips-percent-literal) (ruby-move-to-block-skips-heredoc) (ruby-move-to-block-moves-from-else-to-if) (ruby-beginning-of-defun-does-not-fold-case) (ruby-end-of-defun-skips-to-next-line-after-the-method): Replace goto-line with forward-line/goto-char. (ruby-move-to-block-does-not-fold-case): Remove unneeded end-of-buffer. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-11 16:01:26 +0000 +++ test/ChangeLog 2013-07-11 16:04:56 +0000 @@ -1,5 +1,16 @@ 2013-07-11 Glenn Morris + * automated/ruby-mode-tests.el (ruby-deftest-move-to-block): + Goto point-min. + (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two) + (ruby-move-to-block-skips-percent-literal) + (ruby-move-to-block-skips-heredoc) + (ruby-move-to-block-moves-from-else-to-if) + (ruby-beginning-of-defun-does-not-fold-case) + (ruby-end-of-defun-skips-to-next-line-after-the-method): + Replace goto-line with forward-line/goto-char. + (ruby-move-to-block-does-not-fold-case): Remove unneeded end-of-buffer. + * automated/package-test.el (makeinfo-buffer): Autoload. (compilation-in-progress, tar-parse-info, tar-header-name): Declare. (package-test-install-texinfo): Don't require makeinfo. === modified file 'test/automated/ruby-mode-tests.el' --- test/automated/ruby-mode-tests.el 2013-07-09 07:11:50 +0000 +++ test/automated/ruby-mode-tests.el 2013-07-11 16:04:56 +0000 @@ -475,29 +475,30 @@ (with-temp-buffer (insert ruby-block-test-example) (ruby-mode) + (goto-char (point-min)) ,@body))) (put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) (ruby-deftest-move-to-block works-on-do - (goto-line 11) + (forward-line 10) (ruby-end-of-block) (should (= 13 (line-number-at-pos))) (ruby-beginning-of-block) (should (= 11 (line-number-at-pos)))) (ruby-deftest-move-to-block zero-is-noop - (goto-line 5) + (forward-line 4) (ruby-move-to-block 0) (should (= 5 (line-number-at-pos)))) (ruby-deftest-move-to-block ok-with-three - (goto-line 2) + (forward-line 1) (ruby-move-to-block 3) (should (= 14 (line-number-at-pos)))) (ruby-deftest-move-to-block ok-with-minus-two - (goto-line 10) + (forward-line 9) (ruby-move-to-block -2) (should (= 2 (line-number-at-pos)))) @@ -515,7 +516,7 @@ | | |end"))) (ruby-with-temp-buffer s - (goto-line 1) + (goto-char (point-min)) (ruby-end-of-block) (should (= 5 (line-number-at-pos))) (ruby-beginning-of-block) @@ -530,7 +531,7 @@ | end | eowarn |end") - (goto-line 1) + (goto-char (point-min)) (ruby-end-of-block) (should (= 6 (line-number-at-pos))) (ruby-beginning-of-block) @@ -542,7 +543,6 @@ "foo do | Module.to_s |end") - (end-of-buffer) (let ((case-fold-search t)) (ruby-beginning-of-block)) (should (= 1 (line-number-at-pos))))) @@ -554,7 +554,8 @@ | end |else |end") - (goto-line 4) + (goto-char (point-min)) + (forward-line 3) (ruby-beginning-of-block) (should (= 1 (line-number-at-pos))))) @@ -566,7 +567,8 @@ | Class.to_s | end |end") - (goto-line 4) + (goto-char (point-min)) + (forward-line 3) (let ((case-fold-search t)) (beginning-of-defun)) (should (= 2 (line-number-at-pos))))) @@ -579,7 +581,8 @@ | 'ho hum' | end |end") - (goto-line 2) + (goto-char (point-min)) + (forward-line 1) (end-of-defun) (should (= 5 (line-number-at-pos))))) ------------------------------------------------------------ revno: 113373 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 09:01:26 -0700 message: Silence package-test.el compilation * test/automated/package-test.el (makeinfo-buffer): Autoload. (compilation-in-progress, tar-parse-info, tar-header-name): Declare. (package-test-install-texinfo): Don't require makeinfo. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-11 16:00:05 +0000 +++ test/ChangeLog 2013-07-11 16:01:26 +0000 @@ -1,5 +1,9 @@ 2013-07-11 Glenn Morris + * automated/package-test.el (makeinfo-buffer): Autoload. + (compilation-in-progress, tar-parse-info, tar-header-name): Declare. + (package-test-install-texinfo): Don't require makeinfo. + * automated/files.el: Stop "local variables" confusion. * automated/flymake-tests.el (flymake-tests): Remove unused group. === modified file 'test/automated/package-test.el' --- test/automated/package-test.el 2013-06-27 16:14:05 +0000 +++ test/automated/package-test.el 2013-07-11 16:01:26 +0000 @@ -142,6 +142,9 @@ (let ((help-xref-following t)) ,@body))) +(autoload 'makeinfo-buffer "makeinfo") +(defvar compilation-in-progress) + (defun package-test-install-texinfo (file) "Install from texinfo FILE. @@ -156,7 +159,6 @@ (with-current-buffer (find-file-literally full-file) (unwind-protect (progn - (require 'makeinfo) (makeinfo-buffer) ;; Give `makeinfo-buffer' a chance to finish (while compilation-in-progress @@ -184,6 +186,9 @@ (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes)) (delete-file file)))) +(defvar tar-parse-info) +(declare-function tar-header-name "tar-mode" (cl-x) t) ; defstruct + (defun package-test-search-tar-file (filename) "Search the current buffer's `tar-parse-info' variable for FILENAME. ------------------------------------------------------------ revno: 113372 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 09:00:05 -0700 message: * test/automated/files.el: Stop "local variables" confusion. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-11 15:58:15 +0000 +++ test/ChangeLog 2013-07-11 16:00:05 +0000 @@ -1,5 +1,7 @@ 2013-07-11 Glenn Morris + * automated/files.el: Stop "local variables" confusion. + * automated/flymake-tests.el (flymake-tests): Remove unused group. * automated/icalendar-tests.el (icalendar-tests--do-test-cycle): === modified file 'test/automated/files.el' --- test/automated/files.el 2013-02-03 08:55:45 +0000 +++ test/automated/files.el 2013-07-11 16:00:05 +0000 @@ -146,4 +146,7 @@ (should (file-test--do-local-variables-test str subtest)))))) (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) +;; Stop the above "Local Var..." confusing Emacs. + + ;;; files.el ends here ------------------------------------------------------------ revno: 113371 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 08:58:15 -0700 message: * automated/flymake-tests.el (flymake-tests): Remove unused group. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-11 15:57:45 +0000 +++ test/ChangeLog 2013-07-11 15:58:15 +0000 @@ -1,5 +1,7 @@ 2013-07-11 Glenn Morris + * automated/flymake-tests.el (flymake-tests): Remove unused group. + * automated/icalendar-tests.el (icalendar-tests--do-test-cycle): Use with-current-buffer. === modified file 'test/automated/flymake-tests.el' --- test/automated/flymake-tests.el 2013-06-30 15:10:33 +0000 +++ test/automated/flymake-tests.el 2013-07-11 15:58:15 +0000 @@ -25,9 +25,6 @@ (require 'ert) (require 'flymake) -(defgroup flymake-tests nil - "Test suite for flymake.") - ;; Warning predicate (defun flymake-tests--current-face (file predicate) ------------------------------------------------------------ revno: 113370 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 08:57:45 -0700 message: Silence icalendar-tests.el compilation * test/automated/icalendar-tests.el (icalendar-tests--do-test-cycle): Use with-current-buffer. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-11 15:56:41 +0000 +++ test/ChangeLog 2013-07-11 15:57:45 +0000 @@ -1,5 +1,8 @@ 2013-07-11 Glenn Morris + * automated/icalendar-tests.el (icalendar-tests--do-test-cycle): + Use with-current-buffer. + * automated/undo-tests.el (undo-test-buffer-modified) (undo-test-file-modified): New tests. === modified file 'test/automated/icalendar-tests.el' --- test/automated/icalendar-tests.el 2013-01-01 09:11:05 +0000 +++ test/automated/icalendar-tests.el 2013-07-11 15:57:45 +0000 @@ -1194,8 +1194,7 @@ (should (string= org-input cycled))))) ;; clean up (kill-buffer (find-buffer-visiting temp-diary)) - (save-excursion - (set-buffer (find-buffer-visiting temp-ics)) + (with-current-buffer (find-buffer-visiting temp-ics) (set-buffer-modified-p nil) (kill-buffer (current-buffer))) (delete-file temp-diary) ------------------------------------------------------------ revno: 113369 committer: Glenn Morris branch nick: trunk timestamp: Thu 2013-07-11 08:56:41 -0700 message: * undo-tests.el (undo-test-buffer-modified, undo-test-file-modified): New tests. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-07-09 07:52:25 +0000 +++ test/ChangeLog 2013-07-11 15:56:41 +0000 @@ -1,3 +1,8 @@ +2013-07-11 Glenn Morris + + * automated/undo-tests.el (undo-test-buffer-modified) + (undo-test-file-modified): New tests. + 2013-07-09 Michael Albinus * automated/file-notify-tests.el (file-notify-test00-availability): === modified file 'test/automated/undo-tests.el' --- test/automated/undo-tests.el 2013-06-27 02:00:54 +0000 +++ test/automated/undo-tests.el 2013-07-11 15:56:41 +0000 @@ -200,6 +200,32 @@ '(error "Unrecognized entry in undo list \"bogus\"")))) (buffer-string)))))) +;; http://debbugs.gnu.org/14824 +(ert-deftest undo-test-buffer-modified () + "Test undoing marks buffer unmodified." + (with-temp-buffer + (buffer-enable-undo) + (insert "1") + (undo-boundary) + (set-buffer-modified-p nil) + (insert "2") + (undo) + (should-not (buffer-modified-p)))) + +(ert-deftest undo-test-file-modified () + "Test undoing marks buffer visiting file unmodified." + (let ((tempfile (make-temp-file "undo-test"))) + (unwind-protect + (progn + (with-current-buffer (find-file-noselect tempfile) + (insert "1") + (undo-boundary) + (set-buffer-modified-p nil) + (insert "2") + (undo) + (should-not (buffer-modified-p)))) + (delete-file tempfile)))) + (defun undo-test-all (&optional interactive) "Run all tests for \\[undo]." (interactive "p") ------------------------------------------------------------ revno: 113368 committer: Michael Albinus branch nick: trunk timestamp: Thu 2013-07-11 11:52:54 +0200 message: * net/tramp.el (tramp-methods): Extend docstring. (tramp-connection-timeout): New defcustom. (tramp-error-with-buffer): Reset timestamp only when appropriate. (with-tramp-progress-reporter): Simplify. (tramp-process-actions): Improve messages. * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): * net/tramp-sh.el (tramp-maybe-open-connection): Use `tramp-connection-timeout'. (tramp-methods) [su, sudo, ksu]: Add method specific timeouts. (Bug#14808) diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-11 02:59:54 +0000 +++ lisp/ChangeLog 2013-07-11 09:52:54 +0000 @@ -1,3 +1,17 @@ +2013-07-11 Michael Albinus + + * net/tramp.el (tramp-methods): Extend docstring. + (tramp-connection-timeout): New defcustom. + (tramp-error-with-buffer): Reset timestamp only when appropriate. + (with-tramp-progress-reporter): Simplify. + (tramp-process-actions): Improve messages. + + * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): + * net/tramp-sh.el (tramp-maybe-open-connection): + Use `tramp-connection-timeout'. + (tramp-methods) [su, sudo, ksu]: Add method specific timeouts. + (Bug#14808) + 2013-07-11 Leo Liu * ido.el (ido-read-file-name): Conform to the requirements of === modified file 'lisp/net/tramp-gvfs.el' --- lisp/net/tramp-gvfs.el 2013-05-24 10:03:45 +0000 +++ lisp/net/tramp-gvfs.el 2013-07-11 09:52:54 +0000 @@ -1539,7 +1539,8 @@ ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint" ;; file property. (with-timeout - (60 + ((or (tramp-get-method-parameter method 'tramp-connection-timeout) + tramp-connection-timeout) (if (zerop (length (tramp-file-name-user vec))) (tramp-error vec 'file-error === modified file 'lisp/net/tramp-sh.el' --- lisp/net/tramp-sh.el 2013-07-10 14:58:26 +0000 +++ lisp/net/tramp-sh.el 2013-07-11 09:52:54 +0000 @@ -222,21 +222,24 @@ (tramp-login-program "su") (tramp-login-args (("-") ("%u"))) (tramp-remote-shell "/bin/sh") - (tramp-remote-shell-args ("-c")))) + (tramp-remote-shell-args ("-c")) + (tramp-connection-timeout 10))) ;;;###tramp-autoload (add-to-list 'tramp-methods '("sudo" (tramp-login-program "sudo") (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "Password:"))) (tramp-remote-shell "/bin/sh") - (tramp-remote-shell-args ("-c")))) + (tramp-remote-shell-args ("-c")) + (tramp-connection-timeout 10))) ;;;###tramp-autoload (add-to-list 'tramp-methods '("ksu" (tramp-login-program "ksu") (tramp-login-args (("%u") ("-q"))) (tramp-remote-shell "/bin/sh") - (tramp-remote-shell-args ("-c")))) + (tramp-remote-shell-args ("-c")) + (tramp-connection-timeout 10))) ;;;###tramp-autoload (add-to-list 'tramp-methods '("krlogin" @@ -4442,7 +4445,7 @@ ;; Check whether process is alive. (tramp-barf-if-no-shell-prompt - p 60 + p 10 "Couldn't find local shell prompt for %s" tramp-encoding-shell) ;; Now do all the connections as specified. @@ -4461,6 +4464,9 @@ (async-args (tramp-get-method-parameter l-method 'tramp-async-args)) + (connection-timeout + (tramp-get-method-parameter + l-method 'tramp-connection-timeout)) (gw-args (tramp-get-method-parameter l-method 'tramp-gw-args)) (gw (tramp-get-file-property hop "" "gateway" nil)) @@ -4543,7 +4549,8 @@ (tramp-message vec 3 "Sending command `%s'" command) (tramp-send-command vec command t t) (tramp-process-actions - p vec pos tramp-actions-before-shell 60) + p vec pos tramp-actions-before-shell + (or connection-timeout tramp-connection-timeout)) (tramp-message vec 3 "Found remote shell prompt on `%s'" l-host)) ;; Next hop. === modified file 'lisp/net/tramp.el' --- lisp/net/tramp.el 2013-07-10 15:18:39 +0000 +++ lisp/net/tramp.el 2013-07-11 09:52:54 +0000 @@ -252,6 +252,11 @@ * `tramp-tmpdir' A directory on the remote host for temporary files. If not specified, \"/tmp\" is taken as default. + * `tramp-connection-timeout' + This is the maximum time to be spent for establishing a connection. + In general, the global default value shall be used, but for + some methods, like \"su\" or \"sudo\", a shorter timeout + might be desirable. What does all this mean? Well, you should specify `tramp-login-program' for all methods; this program is used to log in to the remote site. Then, @@ -1034,6 +1039,13 @@ :group 'tramp :type '(choice (const nil) (const t) (const pty))) +(defcustom tramp-connection-timeout 60 + "Defines the max time to wait for establishing a connection (in seconds). +This can be overwritten for different connection types in `tramp-methods'." + :group 'tramp + :version "24.4" + :type 'integer) + (defcustom tramp-connection-min-time-diff 5 "Defines seconds between two consecutive connection attempts. This is necessary as self defense mechanism, in order to avoid @@ -1535,24 +1547,32 @@ If BUFFER is nil, show the connection buffer. Wait for 30\", or until an input event arrives. The other arguments are passed to `tramp-error'." (save-window-excursion - (unwind-protect - (apply 'tramp-error vec-or-proc signal fmt-string args) - (when (and vec-or-proc - tramp-message-show-message - (not (zerop tramp-verbose)) - (not (tramp-completion-mode-p))) - (let ((enable-recursive-minibuffers t)) - (pop-to-buffer - (or (and (bufferp buffer) buffer) - (and (processp vec-or-proc) (process-buffer vec-or-proc)) - (tramp-get-connection-buffer vec-or-proc))) - ;; `tramp-error' does not show messages. So we must do it ourselves. - (message fmt-string args) - (discard-input) - (sit-for 30))) - ;; Reset timestamp. It would be wrong after waiting for a while. - (when tramp-current-connection - (setcdr tramp-current-connection (current-time)))))) + (let* ((buf (or (and (bufferp buffer) buffer) + (and (processp vec-or-proc) (process-buffer vec-or-proc)) + (and (vectorp vec-or-proc) + (tramp-get-connection-buffer vec-or-proc)))) + (vec (or (and (vectorp vec-or-proc) vec-or-proc) + (and buf (with-current-buffer buf + (tramp-dissect-file-name default-directory)))))) + (unwind-protect + (apply 'tramp-error vec-or-proc signal fmt-string args) + ;; Save exit. + (when (and buf + tramp-message-show-message + (not (zerop tramp-verbose)) + (not (tramp-completion-mode-p))) + (let ((enable-recursive-minibuffers t)) + ;; `tramp-error' does not show messages. So we must do it + ;; ourselves. + (message fmt-string args) + ;; Show buffer. + (pop-to-buffer buf) + (discard-input) + (sit-for 30))) + ;; Reset timestamp. It would be wrong after waiting for a while. + (when (equal (butlast (append vec nil) 2) + (car tramp-current-connection)) + (setcdr tramp-current-connection (current-time))))))) (defmacro with-parsed-tramp-file-name (filename var &rest body) "Parse a Tramp filename and make components available in the body. @@ -1596,11 +1616,11 @@ (defmacro with-tramp-progress-reporter (vec level message &rest body) "Executes BODY, spinning a progress reporter with MESSAGE. -If LEVEL does not fit for visible messages, or if this is a -nested call of the macro, there are only traces without a visible -progress reporter." +If LEVEL does not fit for visible messages, there are only traces +without a visible progress reporter." (declare (indent 3) (debug t)) - `(let (pr tm result) + `(let ((result "failed") + pr tm) (tramp-message ,vec ,level "%s..." ,message) ;; We start a pulsing progress reporter after 3 seconds. Feature ;; introduced in Emacs 24.1. @@ -1611,21 +1631,12 @@ (setq pr (tramp-compat-funcall 'make-progress-reporter ,message) tm (when pr (run-at-time 3 0.1 'tramp-progress-reporter-update pr))))) - (condition-case err - (unwind-protect - ;; Execute the body. - (setq result (progn ,@body)) - ;; Stop progress reporter. - (if tm (tramp-compat-funcall 'cancel-timer tm))) - - ;; Error handling. - ((error quit) - (tramp-message ,vec ,level "%s...failed" ,message) - (signal (car err) (cdr err)))) - - ;; Exit. - (tramp-message ,vec ,level "%s...done" ,message) - result)) + (unwind-protect + ;; Execute the body. + (prog1 (progn ,@body) (setq result "done")) + ;; Stop progress reporter. + (if tm (tramp-compat-funcall 'cancel-timer tm)) + (tramp-message ,vec ,level "%s...%s" ,message result)))) (tramp-compat-font-lock-add-keywords 'emacs-lisp-mode '("\\")) @@ -3434,7 +3445,9 @@ "Tramp failed to connect. If this happens repeatedly, try\n" " `M-x tramp-cleanup-this-connection'")) ((eq exit 'timeout) - "Timeout reached. Check the buffer for the error reason") + (format + "Timeout reached, see buffer `%s' for details" + (tramp-get-connection-buffer vec))) (t "Login failed"))))) (when (numberp pos) (with-current-buffer (tramp-get-connection-buffer vec) ------------------------------------------------------------ revno: 113367 author: Paul Eggert committer: Paul Eggert branch nick: trunk timestamp: Thu 2013-07-11 00:17:23 -0700 message: * eval.c (backtrace_function, backtrace_args): Now EXTERNALLY_VISIBLE. This is for .gdbinit xbacktrace. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-11 02:17:47 +0000 +++ src/ChangeLog 2013-07-11 07:17:23 +0000 @@ -1,5 +1,8 @@ 2013-07-11 Paul Eggert + * eval.c (backtrace_function, backtrace_args): Now EXTERNALLY_VISIBLE. + This is for .gdbinit xbacktrace. + * sysdep.c, term.c, termcap.c, terminal.c: Integer-related minor fixes. * sysdep.c (emacs_get_tty): Return void, since nobody uses the value. (emacs_set_tty): Now static. === modified file 'src/eval.c' --- src/eval.c 2013-06-18 07:42:37 +0000 +++ src/eval.c 2013-07-11 07:17:23 +0000 @@ -114,6 +114,13 @@ frame is half-initialized. */ Lisp_Object inhibit_lisp_code; +/* These would ordinarily be static, but they need to be visible to GDB. */ +bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; +Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE; +Lisp_Object backtrace_function (union specbinding *) EXTERNALLY_VISIBLE; +union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE; +union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; + static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); @@ -152,7 +159,7 @@ return pdl->unwind.func; } -static Lisp_Object +Lisp_Object backtrace_function (union specbinding *pdl) { eassert (pdl->kind == SPECPDL_BACKTRACE); @@ -166,7 +173,7 @@ return pdl->bt.nargs; } -static Lisp_Object * +Lisp_Object * backtrace_args (union specbinding *pdl) { eassert (pdl->kind == SPECPDL_BACKTRACE); @@ -205,10 +212,6 @@ /* Helper functions to scan the backtrace. */ -bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; -union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; -union specbinding *backtrace_next (union specbinding *pdl) EXTERNALLY_VISIBLE; - bool backtrace_p (union specbinding *pdl) { return pdl >= specpdl; } ------------------------------------------------------------ revno: 113366 fixes bug: http://debbugs.gnu.org/11861 committer: Leo Liu branch nick: trunk timestamp: Thu 2013-07-11 10:59:54 +0800 message: * ido.el (ido-read-file-name): Conform to the requirements of read-file-name. (ido-read-directory-name): Conform to the requirements of read-directory-name. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-11 01:49:17 +0000 +++ lisp/ChangeLog 2013-07-11 02:59:54 +0000 @@ -1,3 +1,10 @@ +2013-07-11 Leo Liu + + * ido.el (ido-read-file-name): Conform to the requirements of + read-file-name. (Bug#11861) + (ido-read-directory-name): Conform to the requirements of + read-directory-name. + 2013-07-11 Juanma Barranquero * subr.el (delay-warning): New function. === modified file 'lisp/ido.el' --- lisp/ido.el 2013-07-09 05:09:45 +0000 +++ lisp/ido.el 2013-07-11 02:59:54 +0000 @@ -4780,7 +4780,14 @@ (ido-find-literal nil)) (setq ido-exit nil) (setq filename - (ido-read-internal 'file prompt 'ido-file-history default-filename mustmatch initial)) + (ido-read-internal 'file prompt 'ido-file-history + (cond ; Bug#11861. + ((stringp default-filename) default-filename) + ((consp default-filename) (car default-filename)) + ((and (not default-filename) initial) + (expand-file-name initial dir)) + (buffer-file-name buffer-file-name)) + mustmatch initial)) (setq dir ido-current-directory) ; See bug#1516. (cond ((eq ido-exit 'fallback) @@ -4813,8 +4820,13 @@ (ido-directory-too-big-p ido-current-directory))) (ido-work-directory-index -1) (ido-work-file-index -1)) - (setq filename - (ido-read-internal 'dir prompt 'ido-file-history default-dirname mustmatch initial)) + (setq filename (ido-read-internal + 'dir prompt 'ido-file-history + (or default-dirname ; Bug#11861. + (if initial + (expand-file-name initial ido-current-directory) + ido-current-directory)) + mustmatch initial)) (cond ((eq ido-exit 'fallback) (let ((read-file-name-function nil))