• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/

Lines Matching +defs:local +defs:file

11 ;; This file is part of GNU Emacs.
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
31 ;; VC-related activities that are done when you visit a file, so that
69 file is under that sort of version control.
71 when visiting a file managed by that backend.
78 (if (file-directory-p "/usr/sccs")
93 "*What to do if visiting a symbolic link to a file under version control.
94 Editing such a file through the link bypasses the version control system,
97 If this variable is t, VC follows the link and visits the real file,
132 (defun vc-mistrust-permissions (file)
137 (vc-backend-subdirectory-name file)))))
139 (defcustom vc-stay-local t
140 "*Non-nil means use local operations when possible for remote repositories.
142 and past information to determine the current status of a file.
146 only stays local for hosts that match it. Alternatively, the value
148 symbol `except'; then VC always stays local except for hosts matched
150 :type '(choice (const :tag "Always stay local" t)
151 (const :tag "Don't stay local" nil)
154 (regexp :format " stay local,\n%t: %v" :tag "if it matches")
159 (defun vc-stay-local-p (file)
160 "Return non-nil if VC should stay local when handling FILE.
162 (let* ((backend (vc-backend file))
163 (sym (vc-make-backend-sym backend 'stay-local))
164 (stay-local (if (boundp sym) (symbol-value sym) t)))
165 (if (eq stay-local t) (setq stay-local vc-stay-local))
166 (if (symbolp stay-local) stay-local
167 (let ((dirname (if (file-directory-p file)
168 (directory-file-name file)
169 (file-name-directory file))))
171 (or (vc-file-getprop dirname 'vc-stay-local-p)
172 (vc-file-setprop
173 dirname 'vc-stay-local-p
179 (if (eq (car-safe stay-local) 'except)
180 (setq default nil stay-local (cdr stay-local)))
181 (when (consp stay-local)
182 (setq stay-local
183 (mapconcat 'identity stay-local "\\|")))
184 (if (if (string-match stay-local hostname)
192 (make-variable-buffer-local 'vc-mode)
193 (put 'vc-mode 'permanent-local t)
198 This minor mode is automatically activated whenever you visit a file under
206 ;; We need a notion of per-file properties because the version
207 ;; control state of a file is expensive to derive --- we compute
208 ;; them when the file is initially found, keep them up to date
212 (defvar vc-file-prop-obarray (make-vector 17 0)
213 "Obarray for per-file properties.")
217 (defun vc-file-setprop (file property value)
218 "Set per-file VC PROPERTY for FILE to VALUE."
223 (put (intern file vc-file-prop-obarray) property value))
225 (defun vc-file-getprop (file property)
226 "Get per-file VC PROPERTY for FILE."
227 (get (intern file vc-file-prop-obarray) property))
229 (defun vc-file-clearprops (file)
231 (setplist (intern file vc-file-prop-obarray) nil))
277 (defmacro vc-call (fun file &rest args)
278 ;; BEWARE!! `file' is evaluated twice!!
279 `(vc-call-backend (vc-backend ,file) ',fun ,file ,@args))
288 (defun vc-insert-file (file &optional limit blocksize)
291 Optional argument LIMIT is a regexp. If present, the file is inserted
297 (when (file-exists-p file)
299 (insert-file-contents file)
303 (and (< 0 (cadr (insert-file-contents
304 file nil filepos (incf filepos blocksize))))
313 (defun vc-find-root (file witness)
319 (setq file (abbreviate-file-name file))
321 (user (nth 2 (file-attributes file))))
323 (equal file (setq file (file-name-directory file)))
324 (null file)
330 (not (equal user (nth 2 (file-attributes file))))
331 (string-match vc-ignore-dir-regexp file)))
332 (if (file-exists-p (expand-file-name witness file))
333 (setq root file)
334 (setq file (directory-file-name file))))
337 ;; Access functions to file properties
338 ;; (Properties should be _set_ using vc-file-setprop, but
341 ;; only be retrieved by vc-file-getprop if there is no
346 (defun vc-registered (file)
351 file was previously registered under a certain backend, then that
355 ((string-match vc-ignore-dir-regexp (file-name-directory file)) nil)
356 ((and (boundp 'file-name-handler-alist)
357 (setq handler (find-file-name-handler file 'vc-registered)))
359 (funcall handler 'vc-registered file))
361 ;; There is no file name handler.
364 (let ((backend (vc-file-getprop file 'vc-backend)))
367 (and (vc-call-backend b 'registered file)
368 (vc-file-setprop file 'vc-backend b)
374 (vc-file-setprop file 'vc-backend 'none)
377 (defun vc-backend (file)
379 ;; `file' can be nil in several places (typically due to the use of
380 ;; code like (vc-backend buffer-file-name)).
381 (when (stringp file)
382 (let ((property (vc-file-getprop file 'vc-backend)))
388 (t (if (vc-registered file)
389 (vc-file-getprop file 'vc-backend)
392 (defun vc-backend-subdirectory-name (file)
394 (symbol-name (vc-backend file)))
396 (defun vc-name (file)
398 If the file is not registered, or the master name is not known, return nil."
401 (or (vc-file-getprop file 'vc-name)
404 (if (and (vc-backend file)
405 (vc-call-backend (vc-backend file) 'registered file))
406 (vc-file-getprop file 'vc-name))))
408 (defun vc-checkout-model (file)
415 when the user saves the first changes to the file.
424 (or (vc-file-getprop file 'vc-checkout-model)
425 (if (vc-backend file)
426 (vc-file-setprop file 'vc-checkout-model
427 (vc-call checkout-model file)))))
429 (defun vc-user-login-name (file)
431 (or (and (eq (string-match tramp-file-name-regexp file) 0)
433 (let ((default-directory (file-name-directory file)))
435 (if (not (zerop (process-file "whoami" nil t)))
446 (defun vc-state (file)
452 'up-to-date The working file is unmodified with respect to the
455 'edited The working file has been edited by the user. If
456 locking is used for the file, this state means that
459 USER The current version of the working file is locked by
462 'needs-patch The file has not been edited by the user, but there is
464 in the master file.
466 'needs-merge The file has been edited by the user, and there is also
468 the master file. This state can only occur if locking
469 is not used for the file.
471 'unlocked-changes The current version of the working file is not locked,
472 but the working file has been changed with respect
483 (or (vc-file-getprop file 'vc-state)
484 (if (vc-backend file)
485 (vc-file-setprop file 'vc-state
486 (vc-call state-heuristic file)))))
488 (defun vc-recompute-state (file)
492 (vc-file-setprop file 'vc-state (vc-call state file)))
494 (defsubst vc-up-to-date-p (file)
496 (eq (vc-state file) 'up-to-date))
498 (defun vc-default-state-heuristic (backend file)
502 (vc-call-backend backend 'state file))
504 (defun vc-workfile-unchanged-p (file)
506 (let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
507 (lastmod (nth 5 (file-attributes file))))
512 (let ((unchanged (vc-call workfile-unchanged-p file)))
513 (vc-file-setprop file 'vc-checkout-time (if unchanged lastmod 0))
516 (defun vc-default-workfile-unchanged-p (backend file)
522 (vc-call diff file nil nil "*vc*")
529 (vc-find-backend-function (vc-backend file)
533 (vc-call diff file))))))
535 (defun vc-workfile-version (file)
538 (or (vc-file-getprop file 'vc-workfile-version)
539 (if (vc-backend file)
540 (vc-file-setprop file 'vc-workfile-version
541 (vc-call workfile-version file)))))
543 (defun vc-default-registered (backend file)
557 (let ((result (vc-check-master-templates file (symbol-value sym))))
559 (vc-file-setprop file 'vc-name result)
574 (defun vc-check-master-templates (file templates)
581 for the second. If a file with the resulting name exists, it is taken
588 (let ((dirname (or (file-name-directory file) ""))
589 (basename (file-name-nondirectory file)))
594 (if (and trial (file-exists-p trial)
595 ;; Make sure the file we found with name
596 ;; TRIAL is not the source file itself.
598 ;; the file name is truncated (e.g. to 14
602 (file-name-directory trial)))
603 (not (equal (file-attributes file)
604 (file-attributes trial)))))
611 If the buffer is visiting a file registered with version control,
612 then check the file in or out. Otherwise, just change the read-only flag
615 Check-out of a specified version number does not lock the file;
623 (vc-backend buffer-file-name))
627 (defun vc-default-make-version-backups-p (backend file)
632 (defun vc-version-backup-file-name (file &optional rev manual regexp)
633 "Return a backup file name for REV or the current version of FILE.
638 (concat (regexp-quote (file-name-nondirectory file))
640 (expand-file-name (concat (file-name-nondirectory file)
642 ?/ ?_ (or rev (vc-workfile-version file)))
644 (file-name-directory file))))
646 (defun vc-delete-automatic-version-backups (file)
650 'delete-file
651 (directory-files (or (file-name-directory file) default-directory) t
652 (vc-version-backup-file-name file nil nil t)))
654 (file-error nil)))
656 (defun vc-make-version-backup (file)
659 (unless (and (fboundp 'msdos-long-file-names)
660 (not (with-no-warnings (msdos-long-file-names))))
661 (vc-delete-automatic-version-backups file)
663 (copy-file file (vc-version-backup-file-name file)
667 (file-error
670 "diff/revert therefore not local"))))))
674 ;; If the file on disk is still in sync with the repository,
675 ;; and version backups should be made, copy the file to
676 ;; another name. This enables local diffs and local reverting.
677 (let ((file buffer-file-name))
678 (and (vc-backend file)
679 (vc-up-to-date-p file)
680 (eq (vc-checkout-model file) 'implicit)
681 (vc-call make-version-backups-p file)
682 (vc-make-version-backup file))))
686 ;; If the file in the current buffer is under version control,
687 ;; up-to-date, and locking is not used for the file, set
689 (let ((file buffer-file-name))
690 (and (vc-backend file)
691 (or (and (equal (vc-file-getprop file 'vc-checkout-time)
692 (nth 5 (file-attributes file)))
696 (vc-file-setprop file 'vc-checkout-time nil))
698 (vc-up-to-date-p file)
699 (eq (vc-checkout-model file) 'implicit)
700 (vc-file-setprop file 'vc-state 'edited)
701 (vc-mode-line file)
705 (vc-dired-resynch-file file)))))
707 (defun vc-mode-line (file)
711 (interactive (list buffer-file-name))
712 (let ((backend (vc-backend file)))
716 (vc-call mode-line-string file)
718 ;; If the file is locked by some other user, make
720 ;; cannot modify a file that someone else has locked.
721 (and (equal file buffer-file-name)
722 (stringp (vc-state file))
724 ;; If the user is root, and the file is not owner-writable,
727 ;; This way, even root cannot modify a file that isn't locked.
728 (and (equal file buffer-file-name)
731 (zerop (logand (file-modes buffer-file-name) 128))
736 (defun vc-default-mode-line-string (backend file)
740 \"BACKEND-REV\" if the file is up-to-date
741 \"BACKEND:REV\" if the file is edited (or locked by the calling user)
742 \"BACKEND:LOCKER:REV\" if the file is locked by somebody else
744 This function assumes that the file is registered."
746 (let ((state (vc-state file))
747 (rev (vc-workfile-version file)))
760 "If current buffer visits a symbolic link, visit the real file.
761 If the real file is already visited in another buffer, make that buffer
763 (let* ((truename (abbreviate-file-name (file-chase-links buffer-file-name)))
769 ;; In principle, we could do something like set-visited-file-name.
770 ;; However, it can't be exactly the same as set-visited-file-name.
772 (set-buffer (find-file-noselect truename)))
776 (defun vc-default-find-file-hook (backend)
779 (defun vc-find-file-hook ()
780 "Function for `find-file-hook' activating VC mode if appropriate."
781 ;; Recompute whether file is version controlled,
785 (when buffer-file-name
786 (vc-file-clearprops buffer-file-name)
788 ((vc-backend buffer-file-name)
790 (vc-mode-line buffer-file-name)
793 ;; because this is for things that depend on the file name.
794 (set (make-local-variable 'backup-inhibited) t))
795 ;; Let the backend setup any buffer-local things he needs.
796 (vc-call-backend (vc-backend buffer-file-name) 'find-file-hook))
797 ((let ((link-type (and (file-symlink-p buffer-file-name)
798 (vc-backend (file-chase-links buffer-file-name)))))
802 "Warning: symbolic link to %s-controlled source file" link-type))
804 ;; If we already visited this file by following
808 (get-file-buffer
809 (abbreviate-file-name
810 (file-chase-links buffer-file-name))))
813 (message "Followed link to %s" buffer-file-name)
814 (vc-find-file-hook))
817 "Symbolic link to %s-controlled source file; follow link? " link-type))
819 (message "Followed link to %s" buffer-file-name)
820 (vc-find-file-hook))
825 (add-hook 'find-file-hook 'vc-find-file-hook)
827 ;; more hooks, this time for file-not-found
828 (defun vc-file-not-found-hook ()
829 "When file is not found, try to check it out from version control.
831 Used in `find-file-not-found-functions'."
832 ;; When a file does not exist, ignore cached info about it
834 (vc-file-clearprops buffer-file-name)
835 (let ((backend (vc-backend buffer-file-name)))
836 (if backend (vc-call-backend backend 'find-file-not-found-hook))))
838 (defun vc-default-find-file-not-found-hook (backend)
841 (file-name-nondirectory buffer-file-name)))
844 (setq default-directory (file-name-directory buffer-file-name))
845 (not (vc-error-occurred (vc-checkout buffer-file-name))))))
847 (add-hook 'find-file-not-found-functions 'vc-file-not-found-hook)
850 "Discard VC info about a file when we kill its buffer."
851 (if buffer-file-name
852 (vc-file-clearprops buffer-file-name)))
897 (define-key vc-menu-map [vc-rename-file] '("Rename File" . vc-rename-file))
919 ;;(put 'vc-rename-file 'menu-enable 'vc-mode)
930 ;;(put 'vc-register 'menu-enable '(and buffer-file-name (not vc-mode)))