Now on revision 112739. ------------------------------------------------------------ revno: 112739 committer: Leo Liu branch nick: trunk timestamp: Mon 2013-05-27 13:08:04 +0800 message: * progmodes/octave.el (inferior-octave-directory-tracker-resync): New variable. (inferior-octave-directory-tracker): Automatically re-sync default-directory. (octave-help): Improve handling of 'See also'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-27 01:08:43 +0000 +++ lisp/ChangeLog 2013-05-27 05:08:04 +0000 @@ -1,3 +1,11 @@ +2013-05-27 Leo Liu + + * progmodes/octave.el (inferior-octave-directory-tracker-resync): + New variable. + (inferior-octave-directory-tracker): Automatically re-sync + default-directory. + (octave-help): Improve handling of 'See also'. + 2013-05-27 Stefan Monnier * doc-view.el: Minor naming convention tweaks. === modified file 'lisp/progmodes/octave.el' --- lisp/progmodes/octave.el 2013-05-24 19:37:55 +0000 +++ lisp/progmodes/octave.el 2013-05-27 05:08:04 +0000 @@ -885,15 +885,25 @@ (setq list (cdr list))) (set-process-filter proc filter)))) +(defvar inferior-octave-directory-tracker-resync nil) +(make-variable-buffer-local 'inferior-octave-directory-tracker-resync) + (defun inferior-octave-directory-tracker (string) "Tracks `cd' commands issued to the inferior Octave process. Use \\[inferior-octave-resync-dirs] to resync if Emacs gets confused." + (when inferior-octave-directory-tracker-resync + (setq inferior-octave-directory-tracker-resync nil) + (inferior-octave-resync-dirs)) (cond ((string-match "^[ \t]*cd[ \t;]*$" string) (cd "~")) ((string-match "^[ \t]*cd[ \t]+\\([^ \t\n;]*\\)[ \t\n;]*" string) - (with-demoted-errors ; in case directory doesn't exist - (cd (substring string (match-beginning 1) (match-end 1))))))) + (condition-case err + (cd (match-string 1 string)) + (error (setq inferior-octave-directory-tracker-resync t) + (message "%s: `%s'" + (error-message-string err) + (match-string 1 string))))))) (defun inferior-octave-resync-dirs () "Resync the buffer's idea of the current directory. @@ -1627,10 +1637,15 @@ ;; Make 'See also' clickable (with-syntax-table octave-mode-syntax-table (when (re-search-forward "^\\s-*See also:" nil t) - (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" nil t) - (make-text-button (match-beginning 0) - (match-end 0) - :type 'octave-help-function)))) + (let ((end (or (save-excursion (re-search-forward "^\\s-*$" nil t)) + (point-max)))) + (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" end t) + (make-text-button (match-beginning 0) + ;; If the match ends with . exclude it. + (if (eq (char-before (match-end 0)) ?.) + (1- (match-end 0)) + (match-end 0)) + :type 'octave-help-function))))) (octave-help-mode))))) (defcustom octave-source-directories nil ------------------------------------------------------------ revno: 112738 committer: YAMAMOTO Mitsuharu branch nick: trunk timestamp: Mon 2013-05-27 11:03:18 +0900 message: * configure.ac (HAVE_XRANDR): Check availability of XRRGetScreenResources rather than that of XRRQueryExtension. diff: === modified file 'ChangeLog' --- ChangeLog 2013-05-18 12:04:40 +0000 +++ ChangeLog 2013-05-27 02:03:18 +0000 @@ -1,3 +1,8 @@ +2013-05-27 YAMAMOTO Mitsuharu + + * configure.ac (HAVE_XRANDR): Check availability of + XRRGetScreenResources rather than that of XRRQueryExtension. + 2013-05-18 Eli Zaretskii * make-dist (files): Add nt/msysconfig.sh, nt/mingw-cfg.site, === modified file 'configure.ac' --- configure.ac 2013-05-18 05:32:17 +0000 +++ configure.ac 2013-05-27 02:03:18 +0000 @@ -2999,7 +2999,7 @@ if test $HAVE_XRANDR = no; then # Test old way in case pkg-config doesn't have it (older machines). AC_CHECK_HEADER(X11/extensions/Xrandr.h, - [AC_CHECK_LIB(Xrandr, XRRQueryExtension, HAVE_XRANDR=yes)]) + [AC_CHECK_LIB(Xrandr, XRRGetScreenResources, HAVE_XRANDR=yes)]) if test $HAVE_XRANDR = yes; then XRANDR_LIBS=-lXrandr AC_SUBST(XRANDR_LIBS) ------------------------------------------------------------ revno: 112737 committer: Stefan Monnier branch nick: trunk timestamp: Sun 2013-05-26 21:08:43 -0400 message: * lisp/doc-view.el: Minor naming convention tweaks. (desktop-buffer-mode-handlers): Don't add to it repeatedly. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-27 00:59:33 +0000 +++ lisp/ChangeLog 2013-05-27 01:08:43 +0000 @@ -1,5 +1,8 @@ 2013-05-27 Stefan Monnier + * doc-view.el: Minor naming convention tweaks. + (desktop-buffer-mode-handlers): Don't add to it repeatedly. + * image-mode.el (image-mode-reapply-winprops): Call image-mode-winprops even if there's no `display' property yet (bug#14435). === modified file 'lisp/doc-view.el' --- lisp/doc-view.el 2013-05-24 17:42:23 +0000 +++ lisp/doc-view.el 2013-05-27 01:08:43 +0000 @@ -305,9 +305,8 @@ ;;;; Internal Variables -(defvar doc-view-current-converter-processes nil +(defvar-local doc-view--current-converter-processes nil "Only used internally.") -(make-variable-buffer-local 'doc-view-current-converter-processes) (defun doc-view-new-window-function (winprops) ;; (message "New window %s for buf %s" (car winprops) (current-buffer)) @@ -330,7 +329,7 @@ (image-mode-window-put 'overlay ol winprops) (when (and (windowp (car winprops)) (stringp (overlay-get ol 'display)) - (null doc-view-current-converter-processes)) + (null doc-view--current-converter-processes)) ;; We're not displaying an image yet, so let's do so. This happens when ;; the buffer is displayed for the first time. ;; Don't do it if there's a conversion is running, since in that case, it @@ -338,29 +337,25 @@ (with-selected-window (car winprops) (doc-view-goto-page 1))))) -(defvar doc-view-current-files nil - "Only used internally.") -(make-variable-buffer-local 'doc-view-current-files) - -(defvar doc-view-current-timer nil - "Only used internally.") -(make-variable-buffer-local 'doc-view-current-timer) - -(defvar doc-view-current-cache-dir nil - "Only used internally.") -(make-variable-buffer-local 'doc-view-current-cache-dir) - -(defvar doc-view-current-search-matches nil - "Only used internally.") -(make-variable-buffer-local 'doc-view-current-search-matches) - -(defvar doc-view-pending-cache-flush nil - "Only used internally.") - -(defvar doc-view-previous-major-mode nil - "Only used internally.") - -(defvar doc-view-buffer-file-name nil +(defvar-local doc-view--current-files nil + "Only used internally.") + +(defvar-local doc-view--current-timer nil + "Only used internally.") + +(defvar-local doc-view--current-cache-dir nil + "Only used internally.") + +(defvar-local doc-view--current-search-matches nil + "Only used internally.") + +(defvar doc-view--pending-cache-flush nil + "Only used internally.") + +(defvar doc-view--previous-major-mode nil + "Only used internally.") + +(defvar doc-view--buffer-file-name nil "Only used internally. The file name used for conversion. Normally it's the same as `buffer-file-name', but for remote files, compressed files and @@ -488,7 +483,7 @@ (defmacro doc-view-current-slice () `(image-mode-window-get 'slice)) (defun doc-view-last-page-number () - (length doc-view-current-files)) + (length doc-view--current-files)) (defun doc-view-goto-page (page) "View the page given by PAGE." @@ -499,7 +494,7 @@ (when (and (> page len) ;; As long as the converter is running, we don't know ;; how many pages will be available. - (null doc-view-current-converter-processes)) + (null doc-view--current-converter-processes)) (setq page len))) (setf (doc-view-current-page) page (doc-view-current-info) @@ -507,31 +502,31 @@ (propertize (format "Page %d of %d." page len) 'face 'bold) ;; Tell user if converting isn't finished yet - (if doc-view-current-converter-processes + (if doc-view--current-converter-processes " (still converting...)\n" "\n") ;; Display context infos if this page matches the last search - (when (and doc-view-current-search-matches - (assq page doc-view-current-search-matches)) + (when (and doc-view--current-search-matches + (assq page doc-view--current-search-matches)) (concat (propertize "Search matches:\n" 'face 'bold) (let ((contexts "")) (dolist (m (cdr (assq page - doc-view-current-search-matches))) + doc-view--current-search-matches))) (setq contexts (concat contexts " - \"" m "\"\n"))) contexts))))) ;; Update the buffer - ;; We used to find the file name from doc-view-current-files but + ;; We used to find the file name from doc-view--current-files but ;; that's not right if the pages are not generated sequentially - ;; or if the page isn't in doc-view-current-files yet. + ;; or if the page isn't in doc-view--current-files yet. (let ((file (expand-file-name (format doc-view--image-file-pattern page) - (doc-view-current-cache-dir)))) + (doc-view--current-cache-dir)))) (doc-view-insert-image file :pointer 'arrow) (when (and (not (file-exists-p file)) - doc-view-current-converter-processes) + doc-view--current-converter-processes) ;; The PNG file hasn't been generated yet. (funcall doc-view-single-page-converter-function - doc-view-buffer-file-name file page + doc-view--buffer-file-name file page (let ((win (selected-window))) (lambda () (and (eq (current-buffer) (window-buffer win)) @@ -636,13 +631,13 @@ (defun doc-view-kill-proc () "Kill the current converter process(es)." (interactive) - (while (consp doc-view-current-converter-processes) + (while (consp doc-view--current-converter-processes) (ignore-errors ;; Some entries might not be processes, and maybe ;; some are dead already? - (kill-process (pop doc-view-current-converter-processes)))) - (when doc-view-current-timer - (cancel-timer doc-view-current-timer) - (setq doc-view-current-timer nil)) + (kill-process (pop doc-view--current-converter-processes)))) + (when doc-view--current-timer + (cancel-timer doc-view--current-timer) + (setq doc-view--current-timer nil)) (setq mode-line-process nil)) (defun doc-view-kill-proc-and-buffer () @@ -682,21 +677,21 @@ (format "Unable to use temporary directory %s: %s" dir (mapconcat 'identity (cdr error) " ")))))))) -(defun doc-view-current-cache-dir () +(defun doc-view--current-cache-dir () "Return the directory where the png files of the current doc should be saved. It's a subdirectory of `doc-view-cache-directory'." - (if doc-view-current-cache-dir - doc-view-current-cache-dir + (if doc-view--current-cache-dir + doc-view--current-cache-dir ;; Try and make sure doc-view-cache-directory exists and is safe. (doc-view-make-safe-dir doc-view-cache-directory) ;; Now compute the subdirectory to use. - (setq doc-view-current-cache-dir + (setq doc-view--current-cache-dir (file-name-as-directory (expand-file-name (concat (subst-char-in-string ?% ?_ ;; bug#13679 - (file-name-nondirectory doc-view-buffer-file-name)) + (file-name-nondirectory doc-view--buffer-file-name)) "-" - (let ((file doc-view-buffer-file-name)) + (let ((file doc-view--buffer-file-name)) (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-literally file) @@ -846,8 +841,8 @@ (interactive) (doc-view-kill-proc) ;; Clear the old cached files - (when (file-exists-p (doc-view-current-cache-dir)) - (delete-directory (doc-view-current-cache-dir) 'recursive)) + (when (file-exists-p (doc-view--current-cache-dir)) + (delete-directory (doc-view--current-cache-dir) 'recursive)) (kill-local-variable 'doc-view-last-page-number) (doc-view-initiate-display)) @@ -861,11 +856,11 @@ event)) (when (buffer-live-p (process-get proc 'buffer)) (with-current-buffer (process-get proc 'buffer) - (setq doc-view-current-converter-processes - (delq proc doc-view-current-converter-processes)) + (setq doc-view--current-converter-processes + (delq proc doc-view--current-converter-processes)) (setq mode-line-process - (if doc-view-current-converter-processes - (format ":%s" (car doc-view-current-converter-processes)))) + (if doc-view--current-converter-processes + (format ":%s" (car doc-view--current-converter-processes)))) (funcall (process-get proc 'callback)))))) (defun doc-view-start-process (name program args callback) @@ -876,7 +871,7 @@ (expand-file-name "~/"))) (proc (apply 'start-process name doc-view-conversion-buffer program args))) - (push proc doc-view-current-converter-processes) + (push proc doc-view--current-converter-processes) (setq mode-line-process (list (format ":%s" proc))) (set-process-sentinel proc 'doc-view-sentinel) (process-put proc 'buffer (current-buffer)) @@ -939,7 +934,7 @@ The converted PDF is put into the current cache directory, and it is named like ODF with the extension turned to pdf." (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program - (list "-f" "pdf" "-o" (doc-view-current-cache-dir) odf) + (list "-f" "pdf" "-o" (doc-view--current-cache-dir) odf) callback)) (defun doc-view-odf->pdf-converter-soffice (odf callback) @@ -957,7 +952,7 @@ (concat "-env:UserInstallation=file://" tmp-user-install-dir) "--headless" "--convert-to" "pdf" - "--outdir" (doc-view-current-cache-dir) odf) + "--outdir" (doc-view--current-cache-dir) odf) (lambda () (delete-directory tmp-user-install-dir t) (funcall callback))))) @@ -977,16 +972,16 @@ ;; serves as a witness that the conversion is complete. (write-region (prin1-to-string resolution) nil (expand-file-name "resolution.el" - (doc-view-current-cache-dir)) + (doc-view--current-cache-dir)) nil 'silently) - (when doc-view-current-timer - (cancel-timer doc-view-current-timer) - (setq doc-view-current-timer nil)) + (when doc-view--current-timer + (cancel-timer doc-view--current-timer) + (setq doc-view--current-timer nil)) (doc-view-display (current-buffer) 'force)))) ;; Update the displayed pages as soon as they're done generating. (when doc-view-conversion-refresh-interval - (setq doc-view-current-timer + (setq doc-view--current-timer (run-at-time "1 secs" doc-view-conversion-refresh-interval 'doc-view-display (current-buffer))))) @@ -1031,20 +1026,20 @@ (defun doc-view-current-cache-doc-pdf () "Return the name of the doc.pdf in the current cache dir. This file exists only if the current document isn't a PDF or PS file already." - (expand-file-name "doc.pdf" (doc-view-current-cache-dir))) + (expand-file-name "doc.pdf" (doc-view--current-cache-dir))) (defun doc-view-doc->txt (txt callback) "Convert the current document to text and call CALLBACK when done." - (make-directory (doc-view-current-cache-dir) t) + (make-directory (doc-view--current-cache-dir) t) (pcase doc-view-doc-type (`pdf ;; Doc is a PDF, so convert it to TXT - (doc-view-pdf->txt doc-view-buffer-file-name txt callback)) + (doc-view-pdf->txt doc-view--buffer-file-name txt callback)) (`ps ;; Doc is a PS, so convert it to PDF (which will be converted to ;; TXT thereafter). (let ((pdf (doc-view-current-cache-doc-pdf))) - (doc-view-ps->pdf doc-view-buffer-file-name pdf + (doc-view-ps->pdf doc-view--buffer-file-name pdf (lambda () (doc-view-pdf->txt pdf txt callback))))) (`dvi ;; Doc is a DVI. This means that a doc.pdf already exists in its @@ -1077,39 +1072,39 @@ pages)) (defun doc-view-convert-current-doc () - "Convert `doc-view-buffer-file-name' to a set of png files, one file per page. + "Convert `doc-view--buffer-file-name' to a set of png files, one file per page. Those files are saved in the directory given by the function -`doc-view-current-cache-dir'." +`doc-view--current-cache-dir'." ;; Let stale files still display while we recompute the new ones, so only ;; flush the cache when the conversion is over. One of the reasons why it ;; is important to keep displaying the stale page is so that revert-buffer ;; preserves the horizontal/vertical scroll settings (which are otherwise - ;; resets during the redisplay). - (setq doc-view-pending-cache-flush t) + ;; reset during the redisplay). + (setq doc-view--pending-cache-flush t) (let ((png-file (expand-file-name (format doc-view--image-file-pattern "%d") - (doc-view-current-cache-dir)))) - (make-directory (doc-view-current-cache-dir) t) + (doc-view--current-cache-dir)))) + (make-directory (doc-view--current-cache-dir) t) (pcase doc-view-doc-type (`dvi ;; DVI files have to be converted to PDF before Ghostscript can process ;; it. (let ((pdf (doc-view-current-cache-doc-pdf))) - (doc-view-dvi->pdf doc-view-buffer-file-name pdf + (doc-view-dvi->pdf doc-view--buffer-file-name pdf (lambda () (doc-view-pdf/ps->png pdf png-file))))) (`odf ;; ODF files have to be converted to PDF before Ghostscript can ;; process it. (let ((pdf (doc-view-current-cache-doc-pdf)) (opdf (expand-file-name - (concat (file-name-base doc-view-buffer-file-name) + (concat (file-name-base doc-view--buffer-file-name) ".pdf") - doc-view-current-cache-dir)) + doc-view--current-cache-dir)) (png-file png-file)) ;; The unoconv tool only supports an output directory, but no ;; file name. It's named like the input file with the ;; extension replaced by pdf. - (funcall doc-view-odf->pdf-converter-function doc-view-buffer-file-name + (funcall doc-view-odf->pdf-converter-function doc-view--buffer-file-name (lambda () ;; Rename to doc.pdf (rename-file opdf pdf) @@ -1117,10 +1112,10 @@ ((or `pdf `djvu) (let ((pages (doc-view-active-pages))) ;; Convert doc to bitmap images starting with the active pages. - (doc-view-document->bitmap doc-view-buffer-file-name png-file pages))) + (doc-view-document->bitmap doc-view--buffer-file-name png-file pages))) (_ ;; Convert to PNG images. - (doc-view-pdf/ps->png doc-view-buffer-file-name png-file))))) + (doc-view-pdf/ps->png doc-view--buffer-file-name png-file))))) ;;;; Slicing @@ -1171,7 +1166,7 @@ (doc (let ((cache-doc (doc-view-current-cache-doc-pdf))) (if (file-exists-p cache-doc) cache-doc - doc-view-buffer-file-name))) + doc-view--buffer-file-name))) (o (shell-command-to-string (concat doc-view-ghostscript-program " -dSAFER -dBATCH -dNOPAUSE -q -sDEVICE=bbox " @@ -1255,9 +1250,9 @@ (defun doc-view-insert-image (file &rest args) "Insert the given png FILE. ARGS is a list of image descriptors." - (when doc-view-pending-cache-flush + (when doc-view--pending-cache-flush (clear-image-cache) - (setq doc-view-pending-cache-flush nil)) + (setq doc-view--pending-cache-flush nil)) (let ((ol (doc-view-current-overlay))) ;; Only insert the image if the buffer is visible. (when (window-live-p (overlay-get ol 'window)) @@ -1291,7 +1286,7 @@ (list (cons 'slice slice) image) image)) ;; We're trying to display a page that doesn't exist. - (doc-view-current-converter-processes + (doc-view--current-converter-processes ;; Maybe the page doesn't exist *yet*. "Cannot display this page (yet)!") (t @@ -1314,7 +1309,7 @@ (defun doc-view-sort (a b) "Return non-nil if A should be sorted before B. -Predicate for sorting `doc-view-current-files'." +Predicate for sorting `doc-view--current-files'." (or (< (length a) (length b)) (and (= (length a) (length b)) (string< a b)))) @@ -1324,24 +1319,24 @@ If FORCE is non-nil, start viewing even if the document does not have the page we want to view." (with-current-buffer buffer - (let ((prev-pages doc-view-current-files)) - (setq doc-view-current-files - (sort (directory-files (doc-view-current-cache-dir) t + (let ((prev-pages doc-view--current-files)) + (setq doc-view--current-files + (sort (directory-files (doc-view--current-cache-dir) t (format doc-view--image-file-pattern "[0-9]+") t) 'doc-view-sort)) - (unless (eq (length prev-pages) (length doc-view-current-files)) + (unless (eq (length prev-pages) (length doc-view--current-files)) (force-mode-line-update)) (dolist (win (or (get-buffer-window-list buffer nil t) (list t))) (let* ((page (doc-view-current-page win)) (pagefile (expand-file-name (format doc-view--image-file-pattern page) - (doc-view-current-cache-dir)))) + (doc-view--current-cache-dir)))) (when (or force (and (not (member pagefile prev-pages)) - (member pagefile doc-view-current-files))) + (member pagefile doc-view--current-files))) (if (windowp win) (with-selected-window win (cl-assert (eq (current-buffer) buffer) t) @@ -1376,9 +1371,9 @@ (defun doc-view-open-text () "Open a buffer with the current doc's contents as text." (interactive) - (if doc-view-current-converter-processes + (if doc-view--current-converter-processes (message "DocView: please wait till conversion finished.") - (let ((txt (expand-file-name "doc.txt" (doc-view-current-cache-dir)))) + (let ((txt (expand-file-name "doc.txt" (doc-view--current-cache-dir)))) (if (file-readable-p txt) (let ((name (concat "Text contents of " (file-name-nondirectory buffer-file-name))) @@ -1468,25 +1463,25 @@ If BACKWARD is non-nil, jump to the previous match." (interactive "P") (if (and (not new-query) - doc-view-current-search-matches) + doc-view--current-search-matches) (if backward (doc-view-search-previous-match 1) (doc-view-search-next-match 1)) ;; New search, so forget the old results. - (setq doc-view-current-search-matches nil) + (setq doc-view--current-search-matches nil) (let ((txt (expand-file-name "doc.txt" - (doc-view-current-cache-dir)))) + (doc-view--current-cache-dir)))) (if (file-readable-p txt) (progn - (setq doc-view-current-search-matches + (setq doc-view--current-search-matches (doc-view-search-internal (read-from-minibuffer "Regexp: ") txt)) (message "DocView: search yielded %d matches." (doc-view-search-no-of-matches - doc-view-current-search-matches))) + doc-view--current-search-matches))) ;; We must convert to TXT first! - (if doc-view-current-converter-processes + (if doc-view--current-converter-processes (message "DocView: please wait till conversion finished.") (doc-view-doc->txt txt (lambda () (doc-view-search nil)))))))) @@ -1495,28 +1490,28 @@ (interactive "p") (let* ((next-pages (doc-view-remove-if (lambda (i) (<= (car i) (doc-view-current-page))) - doc-view-current-search-matches)) + doc-view--current-search-matches)) (page (car (nth (1- arg) next-pages)))) (if page (doc-view-goto-page page) (when (and - doc-view-current-search-matches + doc-view--current-search-matches (y-or-n-p "No more matches after current page. Wrap to first match? ")) - (doc-view-goto-page (caar doc-view-current-search-matches)))))) + (doc-view-goto-page (caar doc-view--current-search-matches)))))) (defun doc-view-search-previous-match (arg) "Go to the ARGth previous matching page." (interactive "p") (let* ((prev-pages (doc-view-remove-if (lambda (i) (>= (car i) (doc-view-current-page))) - doc-view-current-search-matches)) + doc-view--current-search-matches)) (page (car (nth (1- arg) (nreverse prev-pages))))) (if page (doc-view-goto-page page) (when (and - doc-view-current-search-matches + doc-view--current-search-matches (y-or-n-p "No more matches before current page. Wrap to last match? ")) - (doc-view-goto-page (caar (last doc-view-current-search-matches))))))) + (doc-view-goto-page (caar (last doc-view--current-search-matches))))))) ;;;; User interface commands and the mode @@ -1524,13 +1519,13 @@ (defun doc-view-already-converted-p () "Return non-nil if the current doc was already converted." - (and (file-exists-p (doc-view-current-cache-dir)) + (and (file-exists-p (doc-view--current-cache-dir)) ;; Check that the resolution info is there, otherwise it means ;; the conversion is incomplete. (file-readable-p (expand-file-name "resolution.el" - (doc-view-current-cache-dir))) + (doc-view--current-cache-dir))) (> (length (directory-files - (doc-view-current-cache-dir) + (doc-view--current-cache-dir) nil (format doc-view--image-file-pattern "[0-9]+"))) 0))) @@ -1544,8 +1539,9 @@ (progn (message "DocView: using cached files!") ;; Load the saved resolution. - (let* ((res-file (expand-file-name "resolution.el" - (doc-view-current-cache-dir))) + (let* ((res-file + (expand-file-name "resolution.el" + (doc-view--current-cache-dir))) (res (with-temp-buffer (when (file-readable-p res-file) @@ -1563,7 +1559,7 @@ (message "%s" (concat "No PNG support is available, or some conversion utility for " - (file-name-extension doc-view-buffer-file-name) + (file-name-extension doc-view--buffer-file-name) " files is missing.")) (when (and (executable-find doc-view-pdftotext-program) (y-or-n-p @@ -1622,13 +1618,14 @@ ((looking-at "%PDF") '(pdf)) ((looking-at "\367\002") '(dvi)) ((looking-at "AT&TFORM") '(djvu)))))) - (setq-local doc-view-doc-type - (car (or (doc-view-intersection name-types content-types) - (when (and name-types content-types) - (error "Conflicting types: name says %s but content says %s" - name-types content-types)) - name-types content-types - (error "Cannot determine the document type")))))) + (setq-local + doc-view-doc-type + (car (or (doc-view-intersection name-types content-types) + (when (and name-types content-types) + (error "Conflicting types: name says %s but content says %s" + name-types content-types)) + name-types content-types + (error "Cannot determine the document type")))))) (defun doc-view-set-up-single-converter () "Find the right single-page converter for the current document type" @@ -1658,9 +1655,8 @@ (doc-view-goto-page page) (when slice (apply 'doc-view-set-slice slice))))) -(setq desktop-buffer-mode-handlers - (cons '(doc-view-mode . doc-view-restore-desktop-buffer) - desktop-buffer-mode-handlers)) +(add-to-list 'desktop-buffer-mode-handlers + '(doc-view-mode . doc-view-restore-desktop-buffer)) ;;;###autoload (defun doc-view-mode () @@ -1681,11 +1677,11 @@ (doc-view-fallback-mode) (let* ((prev-major-mode (if (derived-mode-p 'doc-view-mode) - doc-view-previous-major-mode + doc-view--previous-major-mode (unless (eq major-mode 'fundamental-mode) major-mode)))) (kill-all-local-variables) - (setq-local doc-view-previous-major-mode prev-major-mode)) + (setq-local doc-view--previous-major-mode prev-major-mode)) (dolist (var doc-view-saved-settings) (set (make-local-variable (car var)) (cdr var))) @@ -1697,29 +1693,30 @@ (doc-view-make-safe-dir doc-view-cache-directory) ;; Handle compressed files, remote files, files inside archives - (setq-local doc-view-buffer-file-name - (cond - (jka-compr-really-do-compress - ;; FIXME: there's a risk of name conflicts here. - (expand-file-name - (file-name-nondirectory - (file-name-sans-extension buffer-file-name)) - doc-view-cache-directory)) - ;; Is the file readable by local processes? - ;; We used to use `file-remote-p' but it's unclear what it's - ;; supposed to return nil for things like local files accessed via - ;; `su' or via file://... - ((let ((file-name-handler-alist nil)) - (not (and buffer-file-name (file-readable-p buffer-file-name)))) - ;; FIXME: there's a risk of name conflicts here. - (expand-file-name - (if buffer-file-name - (file-name-nondirectory buffer-file-name) - (buffer-name)) - doc-view-cache-directory)) - (t buffer-file-name))) - (when (not (string= doc-view-buffer-file-name buffer-file-name)) - (write-region nil nil doc-view-buffer-file-name)) + (setq-local doc-view--buffer-file-name + (cond + (jka-compr-really-do-compress + ;; FIXME: there's a risk of name conflicts here. + (expand-file-name + (file-name-nondirectory + (file-name-sans-extension buffer-file-name)) + doc-view-cache-directory)) + ;; Is the file readable by local processes? + ;; We used to use `file-remote-p' but it's unclear what it's + ;; supposed to return nil for things like local files accessed + ;; via `su' or via file://... + ((let ((file-name-handler-alist nil)) + (not (and buffer-file-name + (file-readable-p buffer-file-name)))) + ;; FIXME: there's a risk of name conflicts here. + (expand-file-name + (if buffer-file-name + (file-name-nondirectory buffer-file-name) + (buffer-name)) + doc-view-cache-directory)) + (t buffer-file-name))) + (when (not (string= doc-view--buffer-file-name buffer-file-name)) + (write-region nil nil doc-view--buffer-file-name)) (add-hook 'change-major-mode-hook (lambda () @@ -1770,8 +1767,8 @@ '(doc-view-resolution image-mode-winprops-alist))))) (remove-overlays (point-min) (point-max) 'doc-view t) - (if doc-view-previous-major-mode - (funcall doc-view-previous-major-mode) + (if doc-view--previous-major-mode + (funcall doc-view--previous-major-mode) (let ((auto-mode-alist (rassq-delete-all 'doc-view-mode-maybe ------------------------------------------------------------ revno: 112736 fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14435 committer: Stefan Monnier branch nick: trunk timestamp: Sun 2013-05-26 20:59:33 -0400 message: * lisp/image-mode.el (image-mode-reapply-winprops): Call image-mode-winprops even if there's no `display' property yet. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-25 16:05:19 +0000 +++ lisp/ChangeLog 2013-05-27 00:59:33 +0000 @@ -1,6 +1,11 @@ +2013-05-27 Stefan Monnier + + * image-mode.el (image-mode-reapply-winprops): Call image-mode-winprops + even if there's no `display' property yet (bug#14435). + 2013-05-25 Eli Zaretskii - * subr.el (unmsys--file-name): Renamed from reveal-filename. + * subr.el (unmsys--file-name): Rename from reveal-filename. * Makefile.in (custom-deps, finder-data, autoloads) ($(MH_E_DIR)/mh-loaddefs.el, $(TRAMP_DIR)/tramp-loaddefs.el) === modified file 'lisp/image-mode.el' --- lisp/image-mode.el 2013-05-24 17:42:23 +0000 +++ lisp/image-mode.el 2013-05-27 00:59:33 +0000 @@ -104,13 +104,16 @@ (defun image-mode-reapply-winprops () ;; When set-window-buffer, set hscroll and vscroll to what they were ;; last time the image was displayed in this window. - (when (and (image-get-display-property) - (listp image-mode-winprops-alist)) + (when (listp image-mode-winprops-alist) + ;; Beware: this call to image-mode-winprops can't be optimized away, + ;; because it not only gets the winprops data but sets it up if needed + ;; (e.g. it's used by doc-view to display the image in a new window). (let* ((winprops (image-mode-winprops nil t)) (hscroll (image-mode-window-get 'hscroll winprops)) (vscroll (image-mode-window-get 'vscroll winprops))) - (if hscroll (set-window-hscroll (selected-window) hscroll)) - (if vscroll (set-window-vscroll (selected-window) vscroll))))) + (when (image-get-display-property) ;Only do it if we display an image! + (if hscroll (set-window-hscroll (selected-window) hscroll)) + (if vscroll (set-window-vscroll (selected-window) vscroll)))))) (defun image-mode-setup-winprops () ;; Record current scroll settings. @@ -329,9 +332,8 @@ ;;; Image Mode setup -(defvar image-type nil +(defvar-local image-type nil "The image type for the current Image mode buffer.") -(make-variable-buffer-local 'image-type) (defvar-local image-multi-frame nil "Non-nil if image for the current Image mode buffer has multiple frames.") @@ -401,7 +403,6 @@ :help "Toggle image animation"] ["Loop Animation" (lambda () (interactive) -;;; (make-variable-buffer-local 'image-animate-loop) (setq image-animate-loop (not image-animate-loop)) ;; FIXME this is a hacky way to make it affect a currently ;; animating image. @@ -461,8 +462,8 @@ (use-local-map image-mode-map) ;; Use our own bookmarking function for images. - (set (make-local-variable 'bookmark-make-record-function) - 'image-bookmark-make-record) + (setq-local bookmark-make-record-function + #'image-bookmark-make-record) ;; Keep track of [vh]scroll when switching buffers (image-mode-setup-winprops) @@ -561,7 +562,7 @@ elt)) magic-fallback-mode-alist)))) (normal-mode) - (set (make-local-variable 'image-mode-previous-major-mode) major-mode))) + (setq-local image-mode-previous-major-mode major-mode))) ;; Restore `image-type' after `kill-all-local-variables' in `normal-mode'. (setq image-type previous-image-type) ;; Enable image minor mode with `C-c C-c'. @@ -641,9 +642,9 @@ ;; is written with, e.g., C-x C-w. (if (coding-system-equal (coding-system-base buffer-file-coding-system) 'no-conversion) - (set (make-local-variable 'find-file-literally) t)) - ;; Allow navigation of large images - (set (make-local-variable 'auto-hscroll-mode) nil) + (setq-local find-file-literally t)) + ;; Allow navigation of large images. + (setq-local auto-hscroll-mode nil) (setq image-type type) (if (eq major-mode 'image-mode) (setq mode-name (format "Image[%s]" type))) ------------------------------------------------------------ revno: 112735 committer: Aidan Gauland branch nick: trunk timestamp: Sun 2013-05-26 19:54:01 +1200 message: Rewrite Eshell tests using ERT diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2013-05-25 02:03:03 +0000 +++ test/ChangeLog 2013-05-26 07:54:01 +0000 @@ -1,3 +1,7 @@ +2013-05-26 Aidan Gauland + + * tests/eshell.el: Rewrite tests using ERT. + 2013-05-25 Leo Liu * indent/octave.m: Add tests for %!, # and ### comments. === modified file 'test/eshell.el' --- test/eshell.el 2013-01-01 09:11:05 +0000 +++ test/eshell.el 2013-05-26 07:54:01 +0000 @@ -1,4 +1,4 @@ -;;; esh-test.el --- Eshell test suite +;;; tests/eshell.el --- Eshell test suite ;; Copyright (C) 1999-2013 Free Software Foundation, Inc. @@ -21,55 +21,20 @@ ;;; Commentary: -;; The purpose of this module is to verify that Eshell works as -;; expected. To run it on your system, use the command -;; \\[eshell-test]. - -;;; Code: - -(eval-when-compile - (require 'cl-lib) - (require 'eshell) - (require 'esh-util)) -(require 'esh-mode) - -(defgroup eshell-test nil - "This module is meant to ensure that Eshell is working correctly." - :tag "Eshell test suite" - :group 'eshell) - -;;; User Variables: - -(defface eshell-test-ok - '((((class color) (background light)) (:foreground "Green" :bold t)) - (((class color) (background dark)) (:foreground "Green" :bold t))) - "The face used to highlight OK result strings." - :group 'eshell-test) -(define-obsolete-face-alias 'eshell-test-ok-face 'eshell-test-ok "22.1") - -(defface eshell-test-failed - '((((class color) (background light)) (:foreground "OrangeRed" :bold t)) - (((class color) (background dark)) (:foreground "OrangeRed" :bold t)) - (t (:bold t))) - "The face used to highlight FAILED result strings." - :group 'eshell-test) -(define-obsolete-face-alias 'eshell-test-failed-face 'eshell-test-failed "22.1") - -(defcustom eshell-show-usage-metrics nil - "If non-nil, display different usage metrics for each Eshell command." - :set (lambda (symbol value) - (if value - (add-hook 'eshell-mode-hook 'eshell-show-usage-metrics) - (remove-hook 'eshell-mode-hook 'eshell-show-usage-metrics)) - (set symbol value)) - :type '(choice (const :tag "No metrics" nil) - (const :tag "Cons cells consumed" t) - (const :tag "Time elapsed" 0)) - :group 'eshell-test) - -;;; Code: - -(defvar test-buffer) +;; Eshell test suite. + +;;; Code: + +(require 'ert) +(require 'eshell) + +(defmacro with-temp-eshell (&rest body) + "Evaluate BODY in a temporary Eshell buffer." + `(let ((eshell-buffer (eshell t))) + (unwind-protect + (with-current-buffer eshell-buffer + ,@body) + (kill-buffer eshell-buffer)))) (defun eshell-insert-command (text &optional func) "Insert a command at the end of the buffer." @@ -87,335 +52,141 @@ (eshell-insert-command text func) (eshell-match-result regexp)) -(defvar eshell-test-failures nil) - -(defun eshell-run-test (module funcsym label command) - "Test whether FORM evaluates to a non-nil value." - (when (let ((sym (intern-soft (concat "eshell-" (symbol-name module))))) - (or (memq sym (eshell-subgroups 'eshell)) - (eshell-using-module sym))) - (with-current-buffer test-buffer - (insert-before-markers - (format "%-70s " (substring label 0 (min 70 (length label))))) - (insert-before-markers " ....") - (eshell-redisplay)) - (let ((truth (eval command))) - (with-current-buffer test-buffer - (delete-char -6) - (insert-before-markers - "[" (let (str) - (if truth - (progn - (setq str " OK ") - (put-text-property 0 6 'face 'eshell-test-ok str)) - (setq str "FAILED") - (setq eshell-test-failures (1+ eshell-test-failures)) - (put-text-property 0 6 'face 'eshell-test-failed str)) - str) "]") - (add-text-properties (line-beginning-position) (point) - (list 'test-func funcsym)) - (eshell-redisplay))))) - -(defun eshell-test-goto-func () - "Jump to the function that defines a particular test." - (interactive) - (let ((fsym (get-text-property (point) 'test-func))) - (when fsym - (let* ((def (symbol-function fsym)) - (library (locate-library (symbol-file fsym 'defun))) - (name (substring (symbol-name fsym) - (length "eshell-test--"))) - (inhibit-redisplay t)) - (find-file library) - (goto-char (point-min)) - (re-search-forward (concat "^(eshell-deftest\\s-+\\w+\\s-+" - name)) - (beginning-of-line))))) - -(defun eshell-run-one-test (&optional arg) - "Jump to the function that defines a particular test." - (interactive "P") - (let ((fsym (get-text-property (point) 'test-func))) - (when fsym - (beginning-of-line) - (delete-region (point) (line-end-position)) - (let ((test-buffer (current-buffer))) - (set-buffer (let ((inhibit-redisplay t)) - (save-window-excursion (eshell t)))) - (funcall fsym) - (unless arg - (kill-buffer (current-buffer))))))) - -;;;###autoload -(defun eshell-test (&optional arg) - "Test Eshell to verify that it works as expected." - (interactive "P") - (let* ((begin (float-time)) - (test-buffer (get-buffer-create "*eshell test*"))) - (set-buffer (let ((inhibit-redisplay t)) - (save-window-excursion (eshell t)))) - (with-current-buffer test-buffer - (erase-buffer) - (setq major-mode 'eshell-test-mode) - (setq mode-name "EShell Test") - (set (make-local-variable 'eshell-test-failures) 0) - (local-set-key [(control ?c) (control ?c)] 'eshell-test-goto-func) - (local-set-key [(control ?c) (control ?r)] 'eshell-run-one-test) - (local-set-key [(control ?m)] 'eshell-test-goto-func) - (local-set-key [return] 'eshell-test-goto-func) - - (insert "Testing Eshell under " (emacs-version)) - (switch-to-buffer test-buffer) - (delete-other-windows)) - (dolist (funcname (sort (all-completions "eshell-test--" - obarray 'functionp) - 'string-lessp)) - (with-current-buffer test-buffer - (insert "\n")) - (funcall (intern-soft funcname))) - (with-current-buffer test-buffer - (insert (format "\n\n--- %s --- (completed in %d seconds)\n" - (current-time-string) - (- (float-time) begin))) - (message "Eshell test suite completed: %s failure%s" - (if (> eshell-test-failures 0) - (number-to-string eshell-test-failures) - "No") - (if (= eshell-test-failures 1) "" "s")))) - (goto-char eshell-last-output-end) - (unless arg - (kill-buffer (current-buffer)))) - - -(defvar eshell-metric-before-command 0) -(defvar eshell-metric-after-command 0) - -(defun eshell-show-usage-metrics () - "If run at Eshell mode startup, metrics are shown after each command." - (set (make-local-variable 'eshell-metric-before-command) - (if (eq eshell-show-usage-metrics t) - 0 - (current-time))) - (set (make-local-variable 'eshell-metric-after-command) - (if (eq eshell-show-usage-metrics t) - 0 - (current-time))) - - (add-hook 'eshell-pre-command-hook - (function - (lambda () - (setq eshell-metric-before-command - (if (eq eshell-show-usage-metrics t) - (car (memory-use-counts)) - (current-time))))) nil t) - - (add-hook 'eshell-post-command-hook - (function - (lambda () - (setq eshell-metric-after-command - (if (eq eshell-show-usage-metrics t) - (car (memory-use-counts)) - (current-time))) - (eshell-interactive-print - (concat - (int-to-string - (if (eq eshell-show-usage-metrics t) - (- eshell-metric-after-command - eshell-metric-before-command 7) - (- (float-time - eshell-metric-after-command) - (float-time - eshell-metric-before-command)))) - "\n")))) - nil t)) - - -;;; The tests. - -(defmacro eshell-deftest (module name label &rest forms) - (declare (indent 2)) - (if (and (fboundp 'cl-compiling-file) (cl-compiling-file)) - nil - (let ((fsym (intern (concat "eshell-test--" (symbol-name name))))) - `(eval-when-compile - (ignore - (defun ,fsym () ,label - (eshell-run-test (quote ,module) (quote ,fsym) ,label - (quote (progn ,@forms))))))))) - - -(eshell-deftest mode same-window-buffer-names - "`eshell-buffer-name' is a member of `same-window-buffer-names'" - (member eshell-buffer-name same-window-buffer-names)) - -(eshell-deftest mode eshell-directory-exists - "`eshell-directory-name' exists and is writable" - (file-writable-p eshell-directory-name)) - -(eshell-deftest mode eshell-directory-modes - "`eshell-directory-name' has correct access protections" - (or (eshell-under-windows-p) - (= (file-modes eshell-directory-name) - eshell-private-directory-modes))) - -(eshell-deftest mode simple-command-result - "`eshell-command-result' works with a simple command." - (= (eshell-command-result "+ 1 2") 3)) - - -(require 'em-banner) - -(eshell-deftest banner banner-displayed - "Startup banner is displayed at point-min" - (cl-assert eshell-banner-message) - (let ((msg (eval eshell-banner-message))) - (cl-assert msg) - (goto-char (point-min)) - (looking-at msg))) - - -(require 'esh-cmd) - -(eshell-deftest var last-result-var - "\"last result\" variable" - (eshell-command-result-p "+ 1 2; + $$ 2" "3\n5\n")) - -(eshell-deftest var last-result-var2 - "\"last result\" variable" - (eshell-command-result-p "+ 1 2; + $$ $$" "3\n6\n")) - -(eshell-deftest var last-arg-var - "\"last arg\" variable" - (eshell-command-result-p "+ 1 2; + $_ 4" "3\n6\n")) - -(eshell-deftest cmd lisp-command - "Evaluate Lisp command" - (eshell-command-result-p "(+ 1 2)" "3")) - -(eshell-deftest cmd lisp-command-args - "Evaluate Lisp command (ignore args)" - (eshell-command-result-p "(+ 1 2) 3" "3")) - -(eshell-deftest cmd subcommand - "Run subcommand" - (eshell-command-result-p "{+ 1 2}" "3\n")) - -(eshell-deftest cmd subcommand-args - "Run subcommand (ignore args)" - (eshell-command-result-p "{+ 1 2} 3" "3\n")) - -(eshell-deftest cmd subcommand-lisp - "Run subcommand + Lisp form" - (eshell-command-result-p "{(+ 1 2)}" "3\n")) - -(eshell-deftest cmd named-command - "Execute named command" - (eshell-command-result-p "+ 1 2" "3\n")) - - -(require 'esh-mode) - -(eshell-deftest mode major-mode - "Major mode is correct" - (eq major-mode 'eshell-mode)) - -(eshell-deftest mode eshell-mode-variable - "`eshell-mode' is true" - (eq eshell-mode t)) - -(eshell-deftest var window-height - "LINES equals window height" - (let ((eshell-stringify-t t)) - (eshell-command-result-p "= $LINES (window-height)" "t\n"))) - -(eshell-deftest mode command-running-p - "Modeline shows no command running" - (or (featurep 'xemacs) - (not eshell-status-in-modeline) - (and (memq 'eshell-command-running-string mode-line-format) - (equal eshell-command-running-string "--")))) - -(eshell-deftest arg forward-arg - "Move across command arguments" - (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) - (let ((here (point)) begin valid) - (eshell-bol) - (setq begin (point)) - (eshell-forward-argument 4) - (setq valid (= here (point))) - (eshell-backward-argument 4) - (prog1 - (and valid (= begin (point))) - (eshell-bol) - (delete-region (point) (point-max))))) - -(eshell-deftest mode queue-input - "Queue command input" - (eshell-insert-command "sleep 2") - (eshell-insert-command "echo alpha" 'eshell-queue-input) - (let ((count 10)) - (while (and eshell-current-command - (> count 0)) - (sit-for 1 0) - (setq count (1- count)))) - (eshell-match-result "alpha\n")) - -; (eshell-deftest proc send-to-subprocess -; "Send input to a subprocess" -; ;; jww (1999-12-06): what about when bc is unavailable? -; (if (not (eshell-search-path "bc")) -; t -; (eshell-insert-command "bc") -; (eshell-insert-command "1 + 2") -; (sit-for 1 0) -; (forward-line -1) -; (prog1 -; (looking-at "3\n") -; (eshell-insert-command "quit") -; (sit-for 1 0)))) - -(eshell-deftest io flush-output - "Flush previous output" - (eshell-insert-command "echo alpha") - (eshell-kill-output) - (and (eshell-match-result (regexp-quote "*** output flushed ***\n")) - (forward-line) - (= (point) eshell-last-output-start))) - -(eshell-deftest mode run-old-command - "Re-run an old command" - (eshell-insert-command "echo alpha") - (goto-char eshell-last-input-start) - (string= (eshell-get-old-input) "echo alpha")) - - -(require 'esh-var) - -(eshell-deftest var interp-cmd +;;; Tests: + +(ert-deftest eshell-test/simple-command-result () + "Test `eshell-command-result' with a simple command." + (should (equal (eshell-command-result "+ 1 2") 3))) + +(ert-deftest eshell-test/lisp-command () + "Test `eshell-command-result' with an elisp command." + (should (equal (eshell-command-result "(+ 1 2)") 3))) + +(ert-deftest eshell-test/lisp-command-args () + "Test `eshell-command-result' with elisp and trailing args. +Test that trailing arguments outside the S-expression are +ignored. e.g. \"(+ 1 2) 3\" => 3" + (should (equal (eshell-command-result "(+ 1 2) 3") 3))) + +(ert-deftest eshell-test/subcommand () + "Test `eshell-command-result' with a simple subcommand." + (should (equal (eshell-command-result "{+ 1 2}") 3))) + +(ert-deftest eshell-test/subcommand-args () + "Test `eshell-command-result' with a subcommand and trailing args. +Test that trailing arguments outside the subcommand are ignored. +e.g. \"{+ 1 2} 3\" => 3" + (should (equal (eshell-command-result "{+ 1 2} 3") 3))) + +(ert-deftest eshell-test/subcommand-lisp () + "Test `eshell-command-result' with an elisp subcommand and trailing args. +Test that trailing arguments outside the subcommand are ignored. +e.g. \"{(+ 1 2)} 3\" => 3" + (should (equal (eshell-command-result "{(+ 1 2)} 3") 3))) + +(ert-deftest eshell-test/interp-cmd () "Interpolate command result" - (eshell-command-result-p "+ ${+ 1 2} 3" "6\n")) + (should (equal (eshell-command-result "+ ${+ 1 2} 3") 6))) -(eshell-deftest var interp-lisp +(ert-deftest eshell-test/interp-lisp () "Interpolate Lisp form evaluation" - (eshell-command-result-p "+ $(+ 1 2) 3" "6\n")) + (should (equal (eshell-command-result "+ $(+ 1 2) 3") 6))) -(eshell-deftest var interp-concat +(ert-deftest eshell-test/interp-concat () "Interpolate and concat command" - (eshell-command-result-p "+ ${+ 1 2}3 3" "36\n")) + (should (equal (eshell-command-result "+ ${+ 1 2}3 3") 36))) -(eshell-deftest var interp-concat-lisp +(ert-deftest eshell-test/interp-concat-lisp () "Interpolate and concat Lisp form" - (eshell-command-result-p "+ $(+ 1 2)3 3" "36\n")) + (should (equal (eshell-command-result "+ $(+ 1 2)3 3") 36))) -(eshell-deftest var interp-concat2 +(ert-deftest eshell-test/interp-concat2 () "Interpolate and concat two commands" - (eshell-command-result-p "+ ${+ 1 2}${+ 1 2} 3" "36\n")) + (should (equal (eshell-command-result "+ ${+ 1 2}${+ 1 2} 3") 36))) -(eshell-deftest var interp-concat-lisp2 +(ert-deftest eshell-test/interp-concat-lisp2 () "Interpolate and concat two Lisp forms" - (eshell-command-result-p "+ $(+ 1 2)$(+ 1 2) 3" "36\n")) - + (should (equal (eshell-command-result "+ $(+ 1 2)$(+ 1 2) 3") 36))) + +(ert-deftest eshell-test/window-height () + "$LINES should equal (window-height)" + (should (eshell-command-result "= $LINES (window-height)"))) + +(ert-deftest eshell-test/window-width () + "$COLUMNS should equal (window-width)" + (should (eshell-command-result "= $COLUMNS (window-width)"))) + +(ert-deftest eshell-test/last-result-var () + "Test using the \"last result\" ($$) variable" + (with-temp-eshell + (should + (eshell-command-result-p "+ 1 2; + $$ 2" + "3\n5\n")))) + +(ert-deftest eshell-test/last-result-var2 () + "Test using the \"last result\" ($$) variable twice" + (with-temp-eshell + (should + (eshell-command-result-p "+ 1 2; + $$ $$" + "3\n6\n")))) + +(ert-deftest eshell-test/last-arg-var () + "Test using the \"last arg\" ($_) variable" + (with-temp-eshell + (should + (eshell-command-result-p "+ 1 2; + $_ 4" + "3\n6\n")))) + +(ert-deftest eshell-test/command-running-p () + "Modeline should show no command running" + (with-temp-eshell + (let ((eshell-status-in-mode-line t)) + (should (memq 'eshell-command-running-string mode-line-format)) + (should (equal eshell-command-running-string "--"))))) + +(ert-deftest eshell-test/forward-arg () + "Test moving across command arguments" + (with-temp-eshell + (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) + (let ((here (point)) begin valid) + (eshell-bol) + (setq begin (point)) + (eshell-forward-argument 4) + (setq valid (= here (point))) + (eshell-backward-argument 4) + (prog1 + (and valid (= begin (point))) + (eshell-bol) + (delete-region (point) (point-max)))))) + +(ert-deftest eshell-test/queue-input () + "Test queuing command input" + (with-temp-eshell + (eshell-insert-command "sleep 2") + (eshell-insert-command "echo alpha" 'eshell-queue-input) + (let ((count 10)) + (while (and eshell-current-command + (> count 0)) + (sit-for 1) + (setq count (1- count)))) + (should (eshell-match-result "alpha\n")))) + +(ert-deftest eshell-test/flush-output () + "Test flushing of previous output" + (with-temp-eshell + (eshell-insert-command "echo alpha") + (eshell-kill-output) + (should (eshell-match-result (regexp-quote "*** output flushed ***\n"))) + (should (forward-line)) + (should (= (point) eshell-last-output-start)))) + +(ert-deftest eshell-test/run-old-command () + "Re-run an old command" + (with-temp-eshell + (eshell-insert-command "echo alpha") + (goto-char eshell-last-input-start) + (string= (eshell-get-old-input) "echo alpha"))) (provide 'esh-test) -;;; esh-test.el ends here +;;; tests/eshell.el ends here ------------------------------------------------------------ revno: 112734 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2013-05-25 19:05:19 +0300 message: Rename unmsys--filename to unmsys--file-name. diff: === modified file 'leim/ChangeLog' --- leim/ChangeLog 2013-05-25 07:19:50 +0000 +++ leim/ChangeLog 2013-05-25 16:05:19 +0000 @@ -1,7 +1,7 @@ 2013-05-25 Eli Zaretskii * Makefile.in (leim-list.el, check-declare): Replace - reveal-filename with unmsys--filename. + reveal-filename with unmsys--file-name. 2013-05-16 Eli Zaretskii === modified file 'leim/Makefile.in' --- leim/Makefile.in 2013-05-25 07:19:50 +0000 +++ leim/Makefile.in 2013-05-25 16:05:19 +0000 @@ -140,7 +140,7 @@ --eval "(update-leim-list-file \".\")" ; \ else \ ${RUN_EMACS} -l ${buildlisppath}/international/quail \ - --eval "(update-leim-list-file \".\" (unmsys--filename \"${srcdir}\"))" ; \ + --eval "(update-leim-list-file \".\" (unmsys--file-name \"${srcdir}\"))" ; \ fi sed -n '/^[^;]/ p' < ${srcdir}/leim-ext.el >> $@ @@ -199,4 +199,4 @@ check-declare: $(RUN_EMACS) -l $(buildlisppath)/emacs-lisp/check-declare \ - --eval '(check-declare-directory (unmsys--filename "$(srcdir)"))' + --eval '(check-declare-directory (unmsys--file-name "$(srcdir)"))' === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-25 07:19:50 +0000 +++ lisp/ChangeLog 2013-05-25 16:05:19 +0000 @@ -1,6 +1,6 @@ 2013-05-25 Eli Zaretskii - * subr.el (unmsys--filename): Renamed from reveal-filename. + * subr.el (unmsys--file-name): Renamed from reveal-filename. * Makefile.in (custom-deps, finder-data, autoloads) ($(MH_E_DIR)/mh-loaddefs.el, $(TRAMP_DIR)/tramp-loaddefs.el) === modified file 'lisp/Makefile.in' --- lisp/Makefile.in 2013-05-25 07:19:50 +0000 +++ lisp/Makefile.in 2013-05-25 16:05:19 +0000 @@ -164,21 +164,21 @@ custom-deps: doit cd $(lisp); $(setwins_almost); \ echo Directories: $$wins; \ - $(emacs) -l cus-dep --eval '(setq generated-custom-dependencies-file (unmsys--filename "$(lisp)/cus-load.el"))' -f custom-make-dependencies $$wins + $(emacs) -l cus-dep --eval '(setq generated-custom-dependencies-file (unmsys--file-name "$(lisp)/cus-load.el"))' -f custom-make-dependencies $$wins $(lisp)/finder-inf.el: $(MAKE) $(MFLAGS) finder-data finder-data: doit cd $(lisp); $(setwins_almost); \ echo Directories: $$wins; \ - $(emacs) -l finder --eval '(setq generated-finder-keywords-file (unmsys--filename "$(lisp)/finder-inf.el"))' -f finder-compile-keywords-make-dist $$wins + $(emacs) -l finder --eval '(setq generated-finder-keywords-file (unmsys--file-name "$(lisp)/finder-inf.el"))' -f finder-compile-keywords-make-dist $$wins # The chmod +w is to handle env var CVSREAD=1. autoloads: $(LOADDEFS) doit cd $(lisp) && chmod +w $(AUTOGEN_VCS) cd $(lisp); $(setwins_almost); \ echo Directories: $$wins; \ - $(emacs) -l autoload --eval '(setq generated-autoload-file (unmsys--filename "$(lisp)/loaddefs.el"))' -f batch-update-autoloads $$wins + $(emacs) -l autoload --eval '(setq generated-autoload-file (unmsys--file-name "$(lisp)/loaddefs.el"))' -f batch-update-autoloads $$wins # This is required by the bootstrap-emacs target in ../src/Makefile, so # we know that if we have an emacs executable, we also have a subdirs.el. @@ -373,7 +373,7 @@ $(MH_E_DIR)/mh-loaddefs.el: $(MH_E_SRC) $(emacs) -l autoload \ --eval "(setq generate-autoload-cookie \";;;###mh-autoload\")" \ - --eval "(setq generated-autoload-file (unmsys--filename \"$@\"))" \ + --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads $(MH_E_DIR) @@ -391,7 +391,7 @@ $(TRAMP_DIR)/tramp-loaddefs.el: $(TRAMP_SRC) $(emacs) -l autoload \ --eval "(setq generate-autoload-cookie \";;;###tramp-autoload\")" \ - --eval "(setq generated-autoload-file (unmsys--filename \"$@\"))" \ + --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads $(TRAMP_DIR) @@ -413,21 +413,21 @@ $(CAL_DIR)/cal-loaddefs.el: $(CAL_SRC) $(emacs) -l autoload \ --eval "(setq generate-autoload-cookie \";;;###cal-autoload\")" \ - --eval "(setq generated-autoload-file (unmsys--filename \"$@\"))" \ + --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads $(CAL_DIR) $(CAL_DIR)/diary-loaddefs.el: $(CAL_SRC) $(emacs) -l autoload \ --eval "(setq generate-autoload-cookie \";;;###diary-autoload\")" \ - --eval "(setq generated-autoload-file (unmsys--filename \"$@\"))" \ + --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads $(CAL_DIR) $(CAL_DIR)/hol-loaddefs.el: $(CAL_SRC) $(emacs) -l autoload \ --eval "(setq generate-autoload-cookie \";;;###holiday-autoload\")" \ - --eval "(setq generated-autoload-file (unmsys--filename \"$@\"))" \ + --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads $(CAL_DIR) === modified file 'lisp/subr.el' --- lisp/subr.el 2013-05-25 07:19:50 +0000 +++ lisp/subr.el 2013-05-25 16:05:19 +0000 @@ -4697,7 +4697,7 @@ ;; This is used in lisp/Makefile.in and in leim/Makefile.in to ;; generate file names for autoloads, custom-deps, and finder-data. -(defun unmsys--filename (file) +(defun unmsys--file-name (file) "Produce the canonical file name for FILE from its MSYS form. On systems other than MS-Windows, just returns FILE.