1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
;;; vc-xemacs-el --- XEmacs compatiblity library for vc
;; This file is part of XEmacs.
;; XEmacs 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.
;; XEmacs 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 XEmacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(defun vc-xemacs-hg-find-file-hook ()
(if (and (not (member 'hg-find-file-hook find-file-hooks))
(vc-find-root buffer-file-name ".hg"))
(progn
(load "mercurial") ; adds hg-find-file-hook to find-file-hooks
(remove-hook 'find-file-hooks 'vc-xemacs-hg-find-file-hook)
(hg-find-file-hook))))
(add-hook 'find-file-hooks 'vc-xemacs-hg-find-file-hook)
;; Handle default-file-name-coding-system and non-MULE XEmacsen
(defun vc-xemacs-file-name-coding-system ()
(or (when (boundp 'file-name-coding-system)
(or file-name-coding-system (default-value 'file-name-coding-system)))
'binary))
;; Compatibility
(unless (boundp 'temporary-file-directory)
(defvar temporary-file-directory (temp-directory)))
;; Adapted from GNU Emacs' version in subr.el
(unless (fboundp 'make-temp-file)
(defun make-temp-file (prefix &optional dir-flag)
(let (file)
(while (condition-case ()
(progn
(setq file
(make-temp-name
(expand-file-name prefix (temp-directory))))
(if dir-flag
(make-directory file)
(and (not (file-exists-p file))
(write-region "" nil file nil 'silent)))
nil)
(file-already-exists t))
;; the file was somehow created by someone else between
;; `make-temp-name' and `write-region', let's try again
nil)
file)))
;; These two are present in XEmacs >= 21.4.20
(unless (fboundp 'line-end-position)
(defalias 'line-end-position 'point-at-eol))
(unless (fboundp 'line-beginning-position)
(defalias 'line-beginning-position 'point-at-bol))
;; ...and this in >= 21.5
(unless (fboundp 'line-number-at-pos)
(defun line-number-at-pos (&optional pos)
(line-number pos t)))
(unless (fboundp 'subst-char-in-string)
(defun subst-char-in-string (fromchar tochar string &optional inplace)
"Replace FROMCHAR with TOCHAR in STRING each time it occurs.
Unless optional argument INPLACE is non-nil, return a new string."
(let ((i (length string))
(newstr (if inplace string (copy-sequence string))))
(while (> i 0)
(setq i (1- i))
(if (eq (aref newstr i) fromchar)
(aset newstr i tochar)))
newstr)))
(unless (fboundp 'replace-regexp-in-string)
;; Note: fixedcase, subexp, start ignored for now
(defun replace-regexp-in-string (regexp rep string &optional
fixedcase literal subexp start)
(replace-in-string string regexp rep literal)))
;; From GNU Emacs' byte-run.el
(unless (fboundp 'with-no-warnings)
(defun with-no-warnings (&rest body)
(car (last body))))
(unless (fboundp 'match-string-no-properties)
(defalias 'match-string-no-properties 'match-string))
(unless (boundp 'find-file-hook)
(defvaralias 'find-file-hook 'find-file-hooks))
(provide 'vc-xemacs)
|