aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-10-07 23:47:24 -0400
committerStefan Monnier2013-10-07 23:47:24 -0400
commitcc5da1ec4d4c7056a07ad49fb05ac0df5621a75f (patch)
tree9aa303bcd57e65c3483959a73ed3717edb797182
parent35ece233a892e0817a79cf63d2da126574b4ef45 (diff)
downloademacs-cc5da1ec4d4c7056a07ad49fb05ac0df5621a75f.tar.gz
emacs-cc5da1ec4d4c7056a07ad49fb05ac0df5621a75f.zip
* lisp/vc/pcvs.el: Use lexical-binding.
(cvs-temp-buffer, cvs-make-cvs-buffer): Pass some vars in the lexical environment of `eval'. (cvs-mode-run, cvs-mode-do): Change `postproc' to be a function rather than a list of expressions. Adjust callers. * lisp/vc/pcvs-defs.el (cvs-postprocess): Remove, unused.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/vc/pcvs-defs.el7
-rw-r--r--lisp/vc/pcvs.el97
3 files changed, 65 insertions, 51 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 93d09d4b55c..0d860498a10 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,8 +1,16 @@
12013-10-08 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * vc/pcvs.el: Use lexical-binding.
4 (cvs-temp-buffer, cvs-make-cvs-buffer): Pass some vars in the lexical
5 environment of `eval'.
6 (cvs-mode-run, cvs-mode-do): Change `postproc' to be a function rather
7 than a list of expressions. Adjust callers.
8 * vc/pcvs-defs.el (cvs-postprocess): Remove, unused.
9
12013-10-07 Dmitry Gutov <dgutov@yandex.ru> 102013-10-07 Dmitry Gutov <dgutov@yandex.ru>
2 11
3 * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Handle the 12 * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Handle the
4 case of the dot in a chained method call being on the following 13 case of the dot in a chained method call being on the following line.
5 line.
6 14
72013-10-07 Stefan Monnier <monnier@iro.umontreal.ca> 152013-10-07 Stefan Monnier <monnier@iro.umontreal.ca>
8 16
diff --git a/lisp/vc/pcvs-defs.el b/lisp/vc/pcvs-defs.el
index 9dc378e4e27..182a030be25 100644
--- a/lisp/vc/pcvs-defs.el
+++ b/lisp/vc/pcvs-defs.el
@@ -245,13 +245,6 @@ Output from cvs is placed here for asynchronous commands.")
245 245
246 246
247;;;; 247;;;;
248;;;; Internal variables, used in the process buffer.
249;;;;
250
251(defvar cvs-postprocess nil
252 "(Buffer local) what to do once the process exits.")
253
254;;;;
255;;;; Internal variables for the *cvs* buffer. 248;;;; Internal variables for the *cvs* buffer.
256;;;; 249;;;;
257 250
diff --git a/lisp/vc/pcvs.el b/lisp/vc/pcvs.el
index 539e8b43735..1aab1fa665b 100644
--- a/lisp/vc/pcvs.el
+++ b/lisp/vc/pcvs.el
@@ -1,4 +1,4 @@
1;;; pcvs.el --- a front-end to CVS 1;;; pcvs.el --- a front-end to CVS -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1991-2013 Free Software Foundation, Inc. 3;; Copyright (C) 1991-2013 Free Software Foundation, Inc.
4 4
@@ -349,7 +349,7 @@ information and will be read-only unless NORMAL is non-nil. It will be emptied
349from the current buffer." 349from the current buffer."
350 (let* ((cvs-buf (current-buffer)) 350 (let* ((cvs-buf (current-buffer))
351 (info (cdr (assoc cmd cvs-buffer-name-alist))) 351 (info (cdr (assoc cmd cvs-buffer-name-alist)))
352 (name (eval (nth 0 info))) 352 (name (eval (nth 0 info) `((cmd . ,cmd))))
353 (mode (nth 1 info)) 353 (mode (nth 1 info))
354 (dir default-directory) 354 (dir default-directory)
355 (buf (cond 355 (buf (cond
@@ -359,9 +359,10 @@ from the current buffer."
359 (t 359 (t
360 (set (make-local-variable 'cvs-temp-buffer) 360 (set (make-local-variable 'cvs-temp-buffer)
361 (cvs-get-buffer-create 361 (cvs-get-buffer-create
362 (eval cvs-temp-buffer-name) 'noreuse)))))) 362 (eval cvs-temp-buffer-name `((dir . ,dir)))
363 'noreuse))))))
363 364
364 ;; handle the potential pre-existing process 365 ;; Handle the potential pre-existing process.
365 (let ((proc (get-buffer-process buf))) 366 (let ((proc (get-buffer-process buf)))
366 (when (and (not normal) (processp proc) 367 (when (and (not normal) (processp proc)
367 (memq (process-status proc) '(run stop))) 368 (memq (process-status proc) '(run stop)))
@@ -416,7 +417,7 @@ from the current buffer."
416If non-nil, NEW means to create a new buffer no matter what." 417If non-nil, NEW means to create a new buffer no matter what."
417 ;; the real cvs-buffer creation 418 ;; the real cvs-buffer creation
418 (setq dir (cvs-expand-dir-name dir)) 419 (setq dir (cvs-expand-dir-name dir))
419 (let* ((buffer-name (eval cvs-buffer-name)) 420 (let* ((buffer-name (eval cvs-buffer-name `((dir . ,dir))))
420 (buffer 421 (buffer
421 (or (and (not new) 422 (or (and (not new)
422 (eq cvs-reuse-cvs-buffer 'current) 423 (eq cvs-reuse-cvs-buffer 'current)
@@ -569,9 +570,9 @@ If non-nil, NEW means to create a new buffer no matter what."
569 process 'cvs-postprocess 570 process 'cvs-postprocess
570 (if (null rest) 571 (if (null rest)
571 ;; this is the last invocation 572 ;; this is the last invocation
572 postprocess 573 postprocess
573 ;; else, we have to register ourselves to be rerun on the rest 574 ;; else, we have to register ourselves to be rerun on the rest
574 `(cvs-run-process ',args ',rest ',postprocess ',single-dir))) 575 (lambda () (cvs-run-process args rest postprocess single-dir))))
575 (set-process-sentinel process 'cvs-sentinel) 576 (set-process-sentinel process 'cvs-sentinel)
576 (set-process-filter process 'cvs-update-filter) 577 (set-process-filter process 'cvs-update-filter)
577 (set-marker (process-mark process) (point-max)) 578 (set-marker (process-mark process) (point-max))
@@ -675,7 +676,8 @@ it is finished."
675 (error "cvs' process buffer was killed") 676 (error "cvs' process buffer was killed")
676 (with-current-buffer procbuf 677 (with-current-buffer procbuf
677 ;; Do the postprocessing like parsing and such. 678 ;; Do the postprocessing like parsing and such.
678 (save-excursion (eval cvs-postproc))))))) 679 (save-excursion
680 (funcall cvs-postproc)))))))
679 ;; Check whether something is left. 681 ;; Check whether something is left.
680 (when (and procbuf (not (get-buffer-process procbuf))) 682 (when (and procbuf (not (get-buffer-process procbuf)))
681 (with-current-buffer procbuf 683 (with-current-buffer procbuf
@@ -755,7 +757,8 @@ clear what alternative to use.
755- NOARGS will get all the arguments from the *cvs* buffer and will 757- NOARGS will get all the arguments from the *cvs* buffer and will
756 always behave as if called interactively. 758 always behave as if called interactively.
757- DOUBLE is the generic case." 759- DOUBLE is the generic case."
758 (declare (debug (&define sexp lambda-list stringp ("interactive" interactive) def-body)) 760 (declare (debug (&define sexp lambda-list stringp
761 ("interactive" interactive) def-body))
759 (doc-string 3)) 762 (doc-string 3))
760 (let ((style (cvs-cdr fun)) 763 (let ((style (cvs-cdr fun))
761 (fun (cvs-car fun))) 764 (fun (cvs-car fun)))
@@ -1465,7 +1468,7 @@ The POSTPROC specified there (typically `log-edit') is then called,
1465 (set (make-local-variable 'cvs-minor-wrap-function) 'cvs-commit-minor-wrap) 1468 (set (make-local-variable 'cvs-minor-wrap-function) 'cvs-commit-minor-wrap)
1466 (run-hooks 'cvs-mode-commit-hook))) 1469 (run-hooks 'cvs-mode-commit-hook)))
1467 1470
1468(defun cvs-commit-minor-wrap (buf f) 1471(defun cvs-commit-minor-wrap (_buf f)
1469 (let ((cvs-ignore-marks-modif (cvs-mode-mark-get-modif "commit"))) 1472 (let ((cvs-ignore-marks-modif (cvs-mode-mark-get-modif "commit")))
1470 (funcall f))) 1473 (funcall f)))
1471 1474
@@ -1598,24 +1601,25 @@ With prefix argument, prompt for cvs flags."
1598 (interactive (list (cvs-flags-query 'cvs-add-flags "cvs add flags"))) 1601 (interactive (list (cvs-flags-query 'cvs-add-flags "cvs add flags")))
1599 (let ((fis (cvs-mode-marked 'add)) 1602 (let ((fis (cvs-mode-marked 'add))
1600 (needdesc nil) (dirs nil)) 1603 (needdesc nil) (dirs nil))
1601 ;; find directories and look for fis needing a description 1604 ;; Find directories and look for fis needing a description.
1602 (dolist (fi fis) 1605 (dolist (fi fis)
1603 (cond 1606 (cond
1604 ((file-directory-p (cvs-fileinfo->full-name fi)) (push fi dirs)) 1607 ((file-directory-p (cvs-fileinfo->full-name fi)) (push fi dirs))
1605 ((eq (cvs-fileinfo->type fi) 'UNKNOWN) (setq needdesc t)))) 1608 ((eq (cvs-fileinfo->type fi) 'UNKNOWN) (setq needdesc t))))
1606 ;; prompt for description if necessary 1609 ;; Prompt for description if necessary.
1607 (let* ((msg (if (and needdesc 1610 (let* ((msg (if (and needdesc
1608 (or current-prefix-arg (not cvs-add-default-message))) 1611 (or current-prefix-arg (not cvs-add-default-message)))
1609 (read-from-minibuffer "Enter description: ") 1612 (read-from-minibuffer "Enter description: ")
1610 (or cvs-add-default-message ""))) 1613 (or cvs-add-default-message "")))
1611 (flags `("-m" ,msg ,@flags)) 1614 (flags `("-m" ,msg ,@flags))
1612 (postproc 1615 (postproc
1613 ;; setup postprocessing for the directory entries 1616 ;; Setup postprocessing for the directory entries.
1614 (when dirs 1617 (when dirs
1615 `((cvs-run-process (list "-n" "update") 1618 (lambda ()
1616 ',dirs 1619 (cvs-run-process (list "-n" "update")
1617 '(cvs-parse-process t)) 1620 dirs
1618 (cvs-mark-fis-dead ',dirs))))) 1621 (lambda () (cvs-parse-process t)))
1622 (cvs-mark-fis-dead dirs)))))
1619 (cvs-mode-run "add" flags fis :postproc postproc)))) 1623 (cvs-mode-run "add" flags fis :postproc postproc))))
1620 1624
1621(defun-cvs-mode (cvs-mode-diff . DOUBLE) (flags) 1625(defun-cvs-mode (cvs-mode-diff . DOUBLE) (flags)
@@ -1666,10 +1670,7 @@ or \"Conflict\" in the *cvs* buffer."
1666 (fis (car (cvs-partition 'cvs-fileinfo->backup-file marked)))) 1670 (fis (car (cvs-partition 'cvs-fileinfo->backup-file marked))))
1667 (unless (consp fis) 1671 (unless (consp fis)
1668 (error "No files with a backup file selected!")) 1672 (error "No files with a backup file selected!"))
1669 ;; let's extract some info into the environment for `buffer-name' 1673 (set-buffer (cvs-temp-buffer "diff"))
1670 (let* ((dir (cvs-fileinfo->dir (car fis)))
1671 (file (cvs-fileinfo->file (car fis))))
1672 (set-buffer (cvs-temp-buffer "diff")))
1673 (message "cvs diff backup...") 1674 (message "cvs diff backup...")
1674 (cvs-execute-single-file-list fis 'cvs-diff-backup-extractor 1675 (cvs-execute-single-file-list fis 'cvs-diff-backup-extractor
1675 cvs-diff-program flags)) 1676 cvs-diff-program flags))
@@ -1851,15 +1852,16 @@ Signal an error if there is no backup file."
1851 ret))) 1852 ret)))
1852 1853
1853(cl-defun cvs-mode-run (cmd flags fis 1854(cl-defun cvs-mode-run (cmd flags fis
1854 &key (buf (cvs-temp-buffer)) 1855 &key (buf (cvs-temp-buffer))
1855 dont-change-disc cvsargs postproc) 1856 dont-change-disc cvsargs postproc)
1856 "Generic cvs-mode-<foo> function. 1857 "Generic cvs-mode-<foo> function.
1857Executes `cvs CVSARGS CMD FLAGS FIS'. 1858Executes `cvs CVSARGS CMD FLAGS FIS'.
1858BUF is the buffer to be used for cvs' output. 1859BUF is the buffer to be used for cvs' output.
1859DONT-CHANGE-DISC non-nil indicates that the command will not change the 1860DONT-CHANGE-DISC non-nil indicates that the command will not change the
1860 contents of files. This is only used by the parser. 1861 contents of files. This is only used by the parser.
1861POSTPROC is a list of expressions to be evaluated at the very end (after 1862POSTPROC is a function of no argument to be evaluated at the very end (after
1862 parsing if applicable). It will be prepended with `progn' if necessary." 1863 parsing if applicable)."
1864 (unless postproc (setq postproc #'ignore))
1863 (let ((def-dir default-directory)) 1865 (let ((def-dir default-directory))
1864 ;; Save the relevant buffers 1866 ;; Save the relevant buffers
1865 (save-some-buffers nil (lambda () (cvs-is-within-p fis def-dir)))) 1867 (save-some-buffers nil (lambda () (cvs-is-within-p fis def-dir))))
@@ -1878,14 +1880,17 @@ POSTPROC is a list of expressions to be evaluated at the very end (after
1878 (cvs-cleanup-collection cvs-cookies ;cleanup remaining messages 1880 (cvs-cleanup-collection cvs-cookies ;cleanup remaining messages
1879 (eq cvs-auto-remove-handled 'delayed) nil t) 1881 (eq cvs-auto-remove-handled 'delayed) nil t)
1880 (when (fboundp after-mode) 1882 (when (fboundp after-mode)
1881 (setq postproc (append postproc `((,after-mode))))) 1883 (setq postproc (let ((pp postproc))
1884 (lambda () (funcall pp) (funcall after-mode)))))
1882 (when parse 1885 (when parse
1883 (let ((old-fis 1886 (let ((old-fis
1884 (when (member cmd '("status" "update")) ;FIXME: Yuck!! 1887 (when (member cmd '("status" "update")) ;FIXME: Yuck!!
1885 ;; absence of `cvs update' output has a specific meaning. 1888 ;; absence of `cvs update' output has a specific meaning.
1886 (or fis (list (cvs-create-fileinfo 'DIRCHANGE "" "." "")))))) 1889 (or fis (list (cvs-create-fileinfo 'DIRCHANGE "" "." "")))))
1887 (push `(cvs-parse-process ',dont-change-disc nil ',old-fis) postproc))) 1890 (pp postproc))
1888 (setq postproc (if (cdr postproc) (cons 'progn postproc) (car postproc))) 1891 (setq postproc (lambda ()
1892 (cvs-parse-process dont-change-disc nil old-fis)
1893 (funcall pp)))))
1889 (with-current-buffer buf 1894 (with-current-buffer buf
1890 (let ((inhibit-read-only t)) (erase-buffer)) 1895 (let ((inhibit-read-only t)) (erase-buffer))
1891 (message "Running cvs %s ..." cmd) 1896 (message "Running cvs %s ..." cmd)
@@ -1893,7 +1898,7 @@ POSTPROC is a list of expressions to be evaluated at the very end (after
1893 1898
1894 1899
1895(cl-defun cvs-mode-do (cmd flags filter 1900(cl-defun cvs-mode-do (cmd flags filter
1896 &key show dont-change-disc cvsargs postproc) 1901 &key show dont-change-disc cvsargs postproc)
1897 "Generic cvs-mode-<foo> function. 1902 "Generic cvs-mode-<foo> function.
1898Executes `cvs CVSARGS CMD FLAGS' on the selected files. 1903Executes `cvs CVSARGS CMD FLAGS' on the selected files.
1899FILTER is passed to `cvs-applicable-p' to only apply the command to 1904FILTER is passed to `cvs-applicable-p' to only apply the command to
@@ -1915,8 +1920,9 @@ With prefix argument, prompt for cvs flags."
1915 (interactive (list (cvs-flags-query 'cvs-status-flags "cvs status flags"))) 1920 (interactive (list (cvs-flags-query 'cvs-status-flags "cvs status flags")))
1916 (cvs-mode-do "status" flags nil :dont-change-disc t :show t 1921 (cvs-mode-do "status" flags nil :dont-change-disc t :show t
1917 :postproc (when (eq cvs-auto-remove-handled 'status) 1922 :postproc (when (eq cvs-auto-remove-handled 'status)
1918 `((with-current-buffer ,(current-buffer) 1923 (let ((buf (current-buffer)))
1919 (cvs-mode-remove-handled)))))) 1924 (lambda () (with-current-buffer buf
1925 (cvs-mode-remove-handled)))))))
1920 1926
1921(defun-cvs-mode (cvs-mode-tree . SIMPLE) (flags) 1927(defun-cvs-mode (cvs-mode-tree . SIMPLE) (flags)
1922 "Call cvstree using the file under the point as a keyfile." 1928 "Call cvstree using the file under the point as a keyfile."
@@ -1924,7 +1930,7 @@ With prefix argument, prompt for cvs flags."
1924 (cvs-mode-run "status" (cons "-v" flags) (cvs-mode-marked nil "status") 1930 (cvs-mode-run "status" (cons "-v" flags) (cvs-mode-marked nil "status")
1925 :buf (cvs-temp-buffer "tree") 1931 :buf (cvs-temp-buffer "tree")
1926 :dont-change-disc t 1932 :dont-change-disc t
1927 :postproc '((cvs-status-cvstrees)))) 1933 :postproc #'cvs-status-cvstrees))
1928 1934
1929;; cvs log 1935;; cvs log
1930 1936
@@ -1958,7 +1964,7 @@ With a prefix argument, prompt for cvs flags."
1958 (cvs-mode-do "update" flags nil :cvsargs '("-n") :dont-change-disc t)) 1964 (cvs-mode-do "update" flags nil :cvsargs '("-n") :dont-change-disc t))
1959 1965
1960 1966
1961(defun-cvs-mode cvs-mode-ignore (&optional pattern) 1967(defun-cvs-mode cvs-mode-ignore ()
1962 "Arrange so that CVS ignores the selected files. 1968 "Arrange so that CVS ignores the selected files.
1963This command ignores files that are not flagged as `Unknown'." 1969This command ignores files that are not flagged as `Unknown'."
1964 (interactive) 1970 (interactive)
@@ -2065,8 +2071,10 @@ The file is removed and `cvs update FILE' is run."
2065 (cvs-mode-run "update" flags fis-other 2071 (cvs-mode-run "update" flags fis-other
2066 :postproc 2072 :postproc
2067 (when fis-removed 2073 (when fis-removed
2068 `((with-current-buffer ,(current-buffer) 2074 (let ((buf (current-buffer)))
2069 (cvs-mode-run "add" nil ',fis-removed))))))))) 2075 (lambda ()
2076 (with-current-buffer buf
2077 (cvs-mode-run "add" nil fis-removed))))))))))
2070 2078
2071 2079
2072(defun-cvs-mode (cvs-mode-revert-to-rev . NOARGS) (rev) 2080(defun-cvs-mode (cvs-mode-revert-to-rev . NOARGS) (rev)
@@ -2077,11 +2085,14 @@ The file is removed and `cvs update FILE' is run."
2077 (cvs-flags-query 'cvs-idiff-version))))) 2085 (cvs-flags-query 'cvs-idiff-version)))))
2078 (let* ((fis (cvs-mode-marked 'revert "revert" :file t)) 2086 (let* ((fis (cvs-mode-marked 'revert "revert" :file t))
2079 (tag (concat "tmp_pcl_tag_" (make-temp-name ""))) 2087 (tag (concat "tmp_pcl_tag_" (make-temp-name "")))
2080 (untag `((with-current-buffer ,(current-buffer) 2088 (buf (current-buffer))
2081 (cvs-mode-run "tag" (list "-d" ',tag) ',fis)))) 2089 (untag (lambda ()
2082 (update `((with-current-buffer ,(current-buffer) 2090 (with-current-buffer buf
2083 (cvs-mode-run "update" (list "-j" ',tag "-j" ',rev) ',fis 2091 (cvs-mode-run "tag" (list "-d" tag) fis))))
2084 :postproc ',untag))))) 2092 (update (lambda ()
2093 (with-current-buffer buf
2094 (cvs-mode-run "update" (list "-j" tag "-j" rev) fis
2095 :postproc untag)))))
2085 (cvs-mode-run "tag" (list tag) fis :postproc update))) 2096 (cvs-mode-run "tag" (list tag) fis :postproc update)))
2086 2097
2087 2098
@@ -2185,7 +2196,8 @@ to use it on individual files."
2185With prefix argument, prompt for cvs flags." 2196With prefix argument, prompt for cvs flags."
2186 (interactive 2197 (interactive
2187 (list (setq cvs-tag-name 2198 (list (setq cvs-tag-name
2188 (cvs-query-read cvs-tag-name "Tag to delete: " cvs-qtypedesc-tag)) 2199 (cvs-query-read cvs-tag-name "Tag to delete: "
2200 cvs-qtypedesc-tag))
2189 (cvs-flags-query 'cvs-tag-flags "tag flags"))) 2201 (cvs-flags-query 'cvs-tag-flags "tag flags")))
2190 (cvs-mode-do "tag" (append '("-d") flags (list tag)) 2202 (cvs-mode-do "tag" (append '("-d") flags (list tag))
2191 (when cvs-force-dir-tag 'tag))) 2203 (when cvs-force-dir-tag 'tag)))
@@ -2203,6 +2215,7 @@ With prefix argument, prompt for cvs flags."
2203 (byte-compile-file filename)))))) 2215 (byte-compile-file filename))))))
2204 2216
2205;; ChangeLog support. 2217;; ChangeLog support.
2218(defvar add-log-buffer-file-name-function)
2206 2219
2207(defun-cvs-mode cvs-mode-add-change-log-entry-other-window () 2220(defun-cvs-mode cvs-mode-add-change-log-entry-other-window ()
2208 "Add a ChangeLog entry in the ChangeLog of the current directory." 2221 "Add a ChangeLog entry in the ChangeLog of the current directory."