📄 psvn.el
字号:
"."))))))
(defun svn-status-set-user-mark (arg)
"Set a user mark on the current file or directory.
If the cursor is on a file this file is marked and the cursor advances to the next line.
If the cursor is on a directory all files in this directory are marked.
If this function is called with a prefix argument, only the current line is
marked, even if it is a directory."
(interactive "P")
(let ((info (svn-status-get-line-information)))
(if info
(progn
(svn-status-apply-usermark t arg)
(svn-status-next-line 1))
(message "No file on this line - cannot set a mark"))))
(defun svn-status-unset-user-mark (arg)
"Remove a user mark on the current file or directory.
If the cursor is on a file, this file is unmarked and the cursor advances to the next line.
If the cursor is on a directory, all files in this directory are unmarked.
If this function is called with a prefix argument, only the current line is
unmarked, even if is a directory."
(interactive "P")
(let ((info (svn-status-get-line-information)))
(if info
(progn
(svn-status-apply-usermark nil arg)
(svn-status-next-line 1))
(message "No file on this line - cannot unset a mark"))))
(defun svn-status-unset-user-mark-backwards ()
"Remove a user mark from the previous file.
Then move to that line."
;; This is consistent with `dired-unmark-backward' and
;; `cvs-mode-unmark-up'.
(interactive)
(let ((info (save-excursion
(svn-status-next-line -1)
(svn-status-get-line-information))))
(if info
(progn
(svn-status-next-line -1)
(svn-status-apply-usermark nil t))
(message "No file on previous line - cannot unset a mark"))))
(defun svn-status-apply-usermark (set-mark only-this-line)
"Do the work for the various marking/unmarking functions."
(let* ((st-info svn-status-info)
(line-info (svn-status-get-line-information))
(file-name (svn-status-line-info->filename line-info))
(sub-file-regexp (concat "^" (regexp-quote
(file-name-as-directory file-name))))
(newcursorpos-fname)
(i-fname)
(current-line svn-start-of-file-list-line-number))
(while st-info
(when (svn-status-line-info->is-visiblep (car st-info))
(setq current-line (1+ current-line)))
(setq i-fname (svn-status-line-info->filename (car st-info)))
(when (or (string= file-name i-fname)
(string-match sub-file-regexp i-fname))
(when (svn-status-line-info->is-visiblep (car st-info))
(when (or (not only-this-line) (string= file-name i-fname))
(setq newcursorpos-fname i-fname)
(if set-mark
(message "marking: %s" i-fname)
(message "unmarking: %s" i-fname))
;;(message "ui-status: %S" (svn-status-line-info->ui-status (car st-info)))
(setcar (svn-status-line-info->ui-status (car st-info)) set-mark)
(save-excursion
(let ((buffer-read-only nil))
(goto-line current-line)
(delete-region (point-at-bol) (point-at-eol))
(svn-insert-line-in-status-buffer (car st-info))
(delete-char 1))))))
(setq st-info (cdr st-info)))
;;(svn-status-update-buffer)
(svn-status-goto-file-name newcursorpos-fname)))
(defun svn-status-apply-usermark-checked (check-function set-mark)
"Mark or unmark files, whether a given function returns t.
The function is called with the line information. Therefore the svnstatus-line-info->* functions can be
used in the check."
(let ((st-info svn-status-info))
(while st-info
(when (apply check-function (list (car st-info)))
(if set-mark
(when (not (svn-status-line-info->has-usermark (car st-info)))
(message "marking: %s" (svn-status-line-info->filename (car st-info))))
(when (svn-status-line-info->has-usermark (car st-info))
(message "unmarking: %s" (svn-status-line-info->filename (car st-info)))))
(setcar (svn-status-line-info->ui-status (car st-info)) set-mark))
(setq st-info (cdr st-info)))
(svn-status-update-buffer)))
(defun svn-status-mark-unknown (arg)
"Mark all unknown files.
These are the files marked with '?' in the *svn-status* buffer.
If the function is called with a prefix arg, unmark all these files."
(interactive "P")
(svn-status-apply-usermark-checked '(lambda (info) (eq (svn-status-line-info->filemark info) ??)) (not arg)))
(defun svn-status-mark-added (arg)
"Mark all added files.
These are the files marked with 'A' in the *svn-status* buffer.
If the function is called with a prefix arg, unmark all these files."
(interactive "P")
(svn-status-apply-usermark-checked '(lambda (info) (eq (svn-status-line-info->filemark info) ?A)) (not arg)))
(defun svn-status-mark-modified (arg)
"Mark all modified files.
These are the files marked with 'M' in the *svn-status* buffer.
If the function is called with a prefix arg, unmark all these files."
(interactive "P")
(svn-status-apply-usermark-checked '(lambda (info) (eq (svn-status-line-info->filemark info) ?M)) (not arg)))
(defun svn-status-unset-all-usermarks ()
(interactive)
(svn-status-apply-usermark-checked '(lambda (info) t) nil))
(defun svn-status-toggle-hide-unknown ()
(interactive)
(setq svn-status-hide-unknown (not svn-status-hide-unknown))
(svn-status-update-buffer))
(defun svn-status-toggle-hide-unmodified ()
(interactive)
(setq svn-status-hide-unmodified (not svn-status-hide-unmodified))
(svn-status-update-buffer))
(defun svn-status-goto-file-name (name)
;; (message "svn-status-goto-file-name: %s %d" name (point))
(let ((start-pos (point)))
(goto-char (point-min))
(while (< (point) (point-max))
(goto-char (next-overlay-change (point)))
(when (string= name (svn-status-line-info->filename
(svn-status-get-line-information)))
(setq start-pos (+ (point) svn-status-default-column))))
(goto-char start-pos)))
(defun svn-status-find-info-for-file-name (name)
(save-excursion
(let ((info nil))
(goto-char (point-min))
(while (< (point) (point-max))
(goto-char (next-overlay-change (point)))
(when (string= name (svn-status-line-info->filename
(svn-status-get-line-information)))
(setq info (svn-status-get-line-information))))
info)))
(defun svn-status-marked-files ()
"Return all files marked by `svn-status-set-user-mark',
or (if no files were marked) the file under point."
(let* ((st-info svn-status-info)
(file-list))
(while st-info
(when (svn-status-line-info->has-usermark (car st-info))
(setq file-list (append file-list (list (car st-info)))))
(setq st-info (cdr st-info)))
(or file-list
(if (svn-status-get-line-information)
(list (svn-status-get-line-information))
nil))))
(defun svn-status-marked-file-names ()
(mapcar 'svn-status-line-info->filename (svn-status-marked-files)))
(defun svn-status-ui-information-hash-table ()
(let ((st-info svn-status-info)
(svn-status-ui-information (make-hash-table :test 'equal)))
(while st-info
(puthash (svn-status-line-info->filename (car st-info))
(svn-status-line-info->ui-status (car st-info))
svn-status-ui-information)
(setq st-info (cdr st-info)))
svn-status-ui-information))
(defun svn-status-create-arg-file (file-name prefix file-info-list postfix)
(with-temp-file file-name
(insert prefix)
(let ((st-info file-info-list))
(while st-info
(insert (svn-status-line-info->filename (car st-info)))
(insert "\n")
(setq st-info (cdr st-info)))
(insert postfix))))
(defun svn-status-show-process-buffer-internal (&optional scroll-to-top)
(when (eq (current-buffer) "*svn-status*")
(delete-other-windows))
(pop-to-buffer "*svn-process*")
(when svn-status-wash-control-M-in-process-buffers
(svn-status-remove-control-M))
(when scroll-to-top
(goto-char (point-min)))
(other-window 1))
(defun svn-status-show-svn-log (arg)
"Run `svn log' on selected files.
When called with a prefix argument add the following command switches:
no prefix: use whatever is in the string `svn-status-default-log-arguments'
prefix argument of -1: use no arguments
prefix argument of 0: use the -q switch (quiet)
other prefix arguments: use the -v switch (verbose)
See `svn-status-marked-files' for what counts as selected."
(interactive "P")
(let ((switch (cond ((eq arg 0) "-q")
((eq arg -1) "")
(arg "-v")
(t svn-status-default-log-arguments))))
;;(message "show log info for: %S" (svn-status-marked-files))
(svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-marked-files) "")
(if (> (length switch) 0)
(svn-run-svn t t 'log "log" "--targets" svn-status-temp-arg-file switch)
(svn-run-svn t t 'log "log" "--targets" svn-status-temp-arg-file))
(save-excursion
(set-buffer "*svn-process*")
(svn-log-view-mode))))
(defun svn-status-info ()
"Run `svn info' on all selected files.
See `svn-status-marked-files' for what counts as selected."
(interactive)
(svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-marked-files) "")
(svn-run-svn t t 'info "info" "--targets" svn-status-temp-arg-file))
;; Todo: add possiblity to specify the revision
(defun svn-status-blame ()
"Run `svn blame' on the current file."
(interactive)
;;(svn-run-svn t t 'blame "blame" "-r" "BASE" (svn-status-line-info->filename (svn-status-get-line-information))))
(svn-run-svn t t 'blame "blame" (svn-status-line-info->filename (svn-status-get-line-information))))
(defun svn-status-show-svn-diff (arg)
"Run `svn diff' on the current file.
If there is a newer revision in the repository, the diff is done against HEAD, otherwise
compare the working copy with BASE.
If ARG then prompt for revision to diff against."
(interactive "P")
(svn-status-show-svn-diff-internal arg nil))
(defun svn-status-show-svn-diff-for-marked-files (arg)
"Run `svn diff' on all selected files.
See `svn-status-marked-files' for what counts as selected.
If ARG then prompt for revision to diff against, else compare working copy with BASE."
(interactive "P")
(svn-status-show-svn-diff-internal arg t))
(defun svn-status-show-svn-diff-internal (arg &optional use-all-marked-files)
(let* ((fl (if use-all-marked-files
(svn-status-marked-files)
(list (svn-status-get-line-information))))
(clear-buf t)
(revision (if arg
(svn-status-read-revision-string "Diff with files for version: " "PREV")
(if use-all-marked-files
"BASE"
(if (svn-status-line-info->modified-external (car fl)) "HEAD" "BASE")))))
(while fl
(svn-run-svn nil clear-buf 'diff "diff" "-r" revision (svn-status-line-info->filename (car fl)))
(setq clear-buf nil)
(setq fl (cdr fl))))
(svn-status-show-process-buffer-internal t)
(save-excursion
(set-buffer "*svn-process*")
(diff-mode)
(font-lock-fontify-buffer)))
(defun svn-status-show-process-buffer ()
(interactive)
(svn-status-show-process-buffer-internal))
(defun svn-status-add-file (arg)
"Run `svn add' on all selected files.
See `svn-status-marked-files' for what counts as selected.
When this function is called with a prefix argument, use the actual file instead."
(interactive "P")
(message "adding: %S" (svn-status-get-file-list-names (not arg)))
(svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-get-file-list (not arg)) "")
(svn-run-svn t t 'add "add" "--targets"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -