comparison lisp/pcvs.el @ 57505:78b87f4d875f

(cvs-mode-view-file, cvs-mode-view-file-other-window): Add. (cvs-mode-find-file): Add optional `view' arg to enter view mode.
author Kim F. Storm <storm@cua.dk>
date Fri, 15 Oct 2004 23:36:16 +0000
parents 6a5f26b68c3c
children 0d53729c8f7a f3ec05478165
comparison
equal deleted inserted replaced
57504:40ccbcbf8668 57505:78b87f4d875f
1923 "Show a buffer containing the file in another window." 1923 "Show a buffer containing the file in another window."
1924 (interactive (list last-input-event)) 1924 (interactive (list last-input-event))
1925 (cvs-mode-find-file e 'dont-select)) 1925 (cvs-mode-find-file e 'dont-select))
1926 1926
1927 1927
1928 (defun cvs-mode-view-file (e)
1929 "View the file."
1930 (interactive (list last-input-event))
1931 (cvs-mode-find-file e nil t))
1932
1933
1934 (defun cvs-mode-view-file-other-window (e)
1935 "View the file."
1936 (interactive (list last-input-event))
1937 (cvs-mode-find-file e t t))
1938
1939
1928 (defun cvs-find-modif (fi) 1940 (defun cvs-find-modif (fi)
1929 (with-temp-buffer 1941 (with-temp-buffer
1930 (call-process cvs-program nil (current-buffer) nil 1942 (call-process cvs-program nil (current-buffer) nil
1931 "-f" "diff" (cvs-fileinfo->file fi)) 1943 "-f" "diff" (cvs-fileinfo->file fi))
1932 (goto-char (point-min)) 1944 (goto-char (point-min))
1933 (if (re-search-forward "^\\([0-9]+\\)" nil t) 1945 (if (re-search-forward "^\\([0-9]+\\)" nil t)
1934 (string-to-number (match-string 1)) 1946 (string-to-number (match-string 1))
1935 1))) 1947 1)))
1936 1948
1937 1949
1938 (defun cvs-mode-find-file (e &optional other) 1950 (defun cvs-mode-find-file (e &optional other view)
1939 "Select a buffer containing the file. 1951 "Select a buffer containing the file.
1940 With a prefix, opens the buffer in an OTHER window." 1952 With a prefix, opens the buffer in an OTHER window."
1941 (interactive (list last-input-event current-prefix-arg)) 1953 (interactive (list last-input-event current-prefix-arg))
1942 ;; If the event moves point, check that it moves it to a valid location. 1954 ;; If the event moves point, check that it moves it to a valid location.
1943 (when (and (/= (point) (progn (posn-set-point (event-end e)) (point))) 1955 (when (and (/= (point) (progn (posn-set-point (event-end e)) (point)))
1961 (set-buffer cvs-buf) 1973 (set-buffer cvs-buf)
1962 (setq default-directory odir)) 1974 (setq default-directory odir))
1963 (let ((buf (if rev (cvs-retrieve-revision fi rev) 1975 (let ((buf (if rev (cvs-retrieve-revision fi rev)
1964 (find-file-noselect (cvs-fileinfo->full-path fi))))) 1976 (find-file-noselect (cvs-fileinfo->full-path fi)))))
1965 (funcall (cond ((eq other 'dont-select) 'display-buffer) 1977 (funcall (cond ((eq other 'dont-select) 'display-buffer)
1966 (other 'switch-to-buffer-other-window) 1978 (other
1967 (t 'switch-to-buffer)) 1979 (if view 'view-buffer-other-window
1980 'switch-to-buffer-other-window))
1981 (t (if view 'view-buffer 'switch-to-buffer)))
1968 buf) 1982 buf)
1969 (when (and cvs-find-file-and-jump (cvs-applicable-p fi 'diff-base)) 1983 (when (and cvs-find-file-and-jump (cvs-applicable-p fi 'diff-base))
1970 (goto-line (cvs-find-modif fi))) 1984 (goto-line (cvs-find-modif fi)))
1971 buf)))))) 1985 buf))))))
1972 1986