📄 psvn.el
字号:
;;; psvn.el --- Subversion interface for emacs
;; Copyright (C) 2002-2004 by Stefan Reichoer
;; Author: Stefan Reichoer, <xsteve@nit.at>
;; $Id: psvn.el 10110 2004-06-30 19:15:05Z xsteve $
;; psvn.el 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 2, or (at your option)
;; any later version.
;; psvn.el 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 GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary
;; psvn.el is tested with GNU Emacs 21.3 on windows, debian linux
;; with svn 1.03
;; psvn.el is an interface for the revision control tool subversion
;; (see http://subversion.tigris.org)
;; psvn.el provides a similar interface for subversion as pcl-cvs for cvs.
;; At the moment the following commands are implemented:
;; M-x svn-status: run 'svn -status -v'
;; and show the result in the *svn-status* buffer. This buffer uses
;; svn-status mode in which the following keys are defined:
;; g - svn-status-update: run 'svn status -v'
;; C-u g - svn-status-update: run 'svn status -vu'
;; = - svn-status-show-svn-diff run 'svn diff'
;; l - svn-status-show-svn-log run 'svn log'
;; i - svn-status-info run 'svn info'
;; r - svn-status-revert run 'svn revert'
;; U - svn-status-update-cmd run 'svn update'
;; c - svn-status-commit-file run 'svn commit'
;; a - svn-status-add-file run 'svn add'
;; + - svn-status-make-directory run 'svn mkdir'
;; R - svn-status-mv run 'svn mv'
;; C-d - svn-status-rm run 'svn rm'
;; M-c - svn-status-cleanup run 'svn cleanup'
;; b - svn-status-blame run 'svn blame'
;; RET - svn-status-find-file-or-examine-directory
;; ^ - svn-status-examine-parent
;; ~ - svn-status-get-specific-revision
;; E - svn-status-ediff-with-revision
;; s - svn-status-show-process-buffer
;; e - svn-status-toggle-edit-cmd-flag
;; ? - svn-status-toggle-hide-unknown
;; _ - svn-status-toggle-hide-unmodified
;; m - svn-status-set-user-mark
;; u - svn-status-unset-user-mark
;; $ - svn-status-toggle-elide
;; DEL - svn-status-unset-user-mark-backwards
;; * ! - svn-status-unset-all-usermarks
;; * ? - svn-status-mark-unknown
;; * A - svn-status-mark-added
;; * M - svn-status-mark-modified
;; . - svn-status-goto-root-or-return
;; f - svn-status-find-file
;; o - svn-status-find-file-other-window
;; v - svn-status-view-file-other-window
;; I - svn-status-parse-info
;; P l - svn-status-property-list
;; P s - svn-status-property-set
;; P d - svn-status-property-delete
;; P e - svn-status-property-edit-one-entry
;; P i - svn-status-property-ignore-file
;; P I - svn-status-property-ignore-file-extension
;; P C-i - svn-status-property-edit-svn-ignore
;; P k - svn-status-property-set-keyword-list
;; P y - svn-status-property-set-eol-style
;; h - svn-status-use-history
;; q - svn-status-bury-buffer
;; To use psvn.el put the following line in your .emacs:
;; (require 'psvn)
;; Start the svn interface with M-x svn-status
;; The latest version of psvn.el can be found at:
;; http://xsteve.nit.at/prg/emacs/psvn.el
;; Or you can check it out from the subversion repository:
;; svn co http://svn.collab.net/repos/svn/trunk/contrib/client-side/psvn psvn
;; TODO:
;; * shortcut for svn propset svn:keywords "Date" psvn.el
;; * docstrings for the functions
;; * perhaps shortcuts for ranges, dates
;; * when editing the command line - offer help from the svn client
;; * finish svn-status-property-set
;; * eventually use the customize interface
;; * interactive svn-status should complete existing directories only;
;; unfortunately `read-directory-name' doesn't exist in Emacs 21.3
;; * Add repository browser
;; * Improve support for svn blame
;; * Support for editing the log file entries, e.g.:
;; svn propedit --revprop -r9821 svn:log
;; * Better logview mode (allow to show the changeset for a given entry)
;; Overview over the implemented/not (yet) implemented svn sub-commands:
;; * add implemented
;; * blame implemented
;; * cat implemented
;; * checkout (co)
;; * cleanup implemented
;; * commit (ci) implemented
;; * copy (cp)
;; * delete (del, remove, rm) implemented
;; * diff (di) implemented
;; * export
;; * help (?, h)
;; * import
;; * info implemented
;; * list (ls)
;; * log implemented
;; * merge
;; * mkdir implemented
;; * move (mv, rename, ren) implemented
;; * propdel (pdel) implemented
;; * propedit (pedit, pe) not needed
;; * propget (pget, pg) used
;; * proplist (plist, pl) implemented
;; * propset (pset, ps) used
;; * resolved
;; * revert implemented
;; * status (stat, st) implemented
;; * switch (sw)
;; * update (up) implemented
;; For the not yet implemented commands you should use the command line
;; svn client. If there are user requests for any missing commands I will
;; probably implement them.
;; Comments / suggestions and bug reports are welcome!
;;; Code:
;;; user setable variables
(defvar svn-log-edit-file-name "++svn-log++" "*Name of a saved log file.")
(defvar svn-status-hide-unknown nil "*Hide unknown files in *svn-status* buffer.")
(defvar svn-status-hide-unmodified nil "*Hide unmodified files in *svn-status* buffer.")
(defvar svn-status-directory-history nil "*List of visited svn working directories.")
(defvar svn-status-unmark-files-after-list '(commit revert)
"*List of operations after which all user marks will be removed.
Possible values are: commit, revert.")
;;; default arguments to pass to svn commands
(defvar svn-status-default-log-arguments ""
"*Arguments to pass to svn log.
\(used in `svn-status-show-svn-log'; override these by giving prefixes\).")
;;; hooks
(defvar svn-log-edit-mode-hook nil "Hook run when entering `svn-log-edit-mode'.")
(defvar svn-status-wash-control-M-in-process-buffers
(eq system-type 'windows-nt)
"*Remove any trailing ^M from the *svn-process* buffer.")
;;; Customize group
(defgroup psvn nil
"Subversion interface for Emacs."
:group 'tools)
(defgroup psvn-faces nil
"psvn faces."
:group 'psvn)
(eval-and-compile
(require 'cl)
(defconst svn-xemacsp (featurep 'xemacs))
(if svn-xemacsp
(require 'overlay)
(require 'overlay nil t)))
;; Use the normally used mode for files ending in .~HEAD~, .~BASE~, ...
(add-to-list 'auto-mode-alist '("\\.~?\\(HEAD\\|BASE\\|PREV\\)~?\\'" ignore t))
;;; internal variables
(defvar svn-process-cmd nil)
(defvar svn-status-info nil)
(defvar svn-status-base-info nil)
(defvar svn-status-initial-window-configuration nil)
(defvar svn-status-default-column 23)
(defvar svn-status-default-revision-width 4)
(defvar svn-status-default-author-width 9)
(defvar svn-status-line-format " %c%c %4s %4s %-9s")
(defvar svn-status-short-mod-flag-p t)
(defvar svn-start-of-file-list-line-number 0)
(defvar svn-status-files-to-commit nil)
(defvar svn-status-pre-commit-window-configuration nil)
(defvar svn-status-pre-propedit-window-configuration nil)
(defvar svn-status-head-revision nil)
(defvar svn-status-root-return-info nil)
(defvar svn-status-property-edit-must-match-flag nil)
(defvar svn-status-propedit-property-name nil)
(defvar svn-status-propedit-file-list nil)
(defvar svn-status-mode-line-process "")
(defvar svn-status-mode-line-process-status "")
(defvar svn-status-mode-line-process-edit-flag "")
(defvar svn-status-edit-svn-command nil)
(defvar svn-status-update-previous-process-output nil)
(defvar svn-status-temp-dir
(or
(when (boundp 'temporary-file-directory) temporary-file-directory) ;emacs
(when (boundp 'temp-directory) temp-directory) ;xemacs
"/tmp/"))
(defvar svn-temp-suffix (make-temp-name "."))
(defvar svn-status-temp-file-to-remove nil)
(defvar svn-status-temp-arg-file (concat svn-status-temp-dir "svn.arg" svn-temp-suffix))
;;; faces
(defface svn-status-marked-face
'((((type tty) (class color)) (:foreground "green" :weight light))
(((class color) (background light)) (:foreground "green3"))
(((class color) (background dark)) (:foreground "palegreen2"))
(t (:weight bold)))
"Face to highlight the mark for user marked files in svn status buffers."
:group 'psvn-faces)
(defface svn-status-modified-external-face
'((((type tty) (class color)) (:foreground "magenta" :weight light))
(((class color) (background light)) (:foreground "magenta"))
(((class color) (background dark)) (:foreground "yellow"))
(t (:weight bold)))
"Face to highlight the phrase \"externally modified\" in *svn-status* buffers."
:group 'psvn-faces)
;based on cvs-filename-face
(defface svn-status-directory-face
'((((type tty) (class color)) (:foreground "lightblue" :weight light))
(((class color) (background light)) (:foreground "blue4"))
(((class color) (background dark)) (:foreground "lightskyblue1"))
(t (:weight bold)))
"Face for directories in svn status buffers.
See `svn-status--line-info->directory-p' for what counts as a directory."
:group 'psvn-faces)
;based on font-lock-comment-face
(defface svn-status-filename-face
'((((class color) (background light)) (:foreground "chocolate"))
(((class color) (background dark)) (:foreground "beige")))
"Face for non-directories in svn status buffers.
See `svn-status--line-info->directory-p' for what counts as a directory."
:group 'psvn-faces)
(defvar svn-highlight t)
;; stolen from PCL-CVS
(defun svn-add-face (str face &optional keymap)
(when svn-highlight
;; Do not use `list*'; cl.el might not have been loaded. We could
;; put (require 'cl) at the top but let's try to manage without.
(add-text-properties 0 (length str)
`(face ,face
,@(when keymap
`(mouse-face highlight
local-map ,keymap)))
str))
str)
(defun svn-status-maybe-add-face (condition text face)
"If CONDITION then add FACE to TEXT.
Else return TEXT unchanged."
(if condition
(svn-add-face text face)
text))
(defun svn-status-choose-face-to-add (condition text face1 face2)
"If CONDITION then add FACE1 to TEXT, else add FACE2 to TEXT."
(if condition
(svn-add-face text face1)
(svn-add-face text face2)))
; compatibility
; emacs 20
(unless (fboundp 'point-at-eol) (defalias 'point-at-eol 'line-end-position))
(unless (fboundp 'point-at-bol) (defalias 'point-at-bol 'line-beginning-position))
(unless (functionp 'read-directory-name) (defalias 'read-directory-name 'read-file-name))
(eval-when-compile
(if (not (fboundp 'gethash))
(require 'cl-macs)))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -