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

Lines Matching +defs:temp +defs:file +defs:name

3 ;;; The author has placed this file in the public domain.
5 ;; This file is part of GNU Emacs.
95 "Emerge mode is used by the Emerge file-merging package.
129 ;; All that can be configured is the name of the programs to execute
131 ;; to be provided (emerge-diff-options). The order in which the file names
133 ;; The file names are always expanded (see expand-file-name) before being
138 ;; way they number lines of a file.
145 Its arguments are the ancestor file and the two variant files."
191 If nil: In such circumstances, the A or B file that is present will be
192 copied to the designated output file."
237 "Last directory for the first file of an `emerge-files...' command.")
239 "Last directory for the second file of an `emerge-files...' command.")
241 "Last directory for the ancestor file of an `emerge-files...' command.")
243 "Last directory for the output file of an `emerge-files...' command.")
245 "Last RCS revision used for first file of an `emerge-revisions...' command.")
247 "Last RCS revision used for second file of an `emerge-revisions...' command.")
249 "Last RCS revision used for ancestor file of an `emerge-revisions...' command.")
260 (defvar emerge-file-out)
300 (defcustom emerge-temp-file-prefix
301 (expand-file-name "emerge" temporary-file-directory)
302 "*Prefix to put on Emerge temporary file names.
307 (defcustom emerge-temp-file-mode 384 ; u=rw only
391 (define-key emerge-basic-keymap "xf" 'emerge-file-names)
406 ;; Suppress write-file and save-buffer
407 (define-key emerge-fast-keymap [remap write-file] 'emerge-query-write-file)
500 "The buffer in which the merged file is manipulated.")
508 buffer-auto-save-file-name)
541 prefer-A in a three-file merge, the A variant is the preferred
543 prefer-B in a three-file merge, the B variant is the preferred
567 "Describes output destination of emerge, for `emerge-file-names'.")
569 ;;; Setup functions for two-file mode.
571 (defun emerge-files-internal (file-A file-B &optional startup-hooks quit-hooks
572 output-file)
573 (if (not (file-readable-p file-A))
574 (error "File `%s' does not exist or is not readable" file-A))
575 (if (not (file-readable-p file-B))
576 (error "File `%s' does not exist or is not readable" file-B))
577 (let ((buffer-A (find-file-noselect file-A))
578 (buffer-B (find-file-noselect file-B)))
580 (setq emerge-last-dir-A (file-name-directory file-A))
581 (setq emerge-last-dir-B (file-name-directory file-B))
582 (if output-file
583 (setq emerge-last-dir-output (file-name-directory output-file)))
588 (let ((temp (file-local-copy file-A)))
589 (if temp
590 (setq file-A temp
592 (cons `(lambda () (delete-file ,file-A))
594 ;; Verify that the file matches the buffer
595 (emerge-verify-file-buffer))))
599 (let ((temp (file-local-copy file-B)))
600 (if temp
601 (setq file-B temp
603 (cons `(lambda () (delete-file ,file-B))
605 ;; Verify that the file matches the buffer
606 (emerge-verify-file-buffer))))
607 (emerge-setup buffer-A file-A buffer-B file-B startup-hooks quit-hooks
608 output-file)))
611 (defun emerge-setup (buffer-A file-A buffer-B file-B startup-hooks quit-hooks
612 output-file)
613 (setq file-A (expand-file-name file-A))
614 (setq file-B (expand-file-name file-B))
615 (setq output-file (and output-file (expand-file-name output-file)))
616 (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*"))
621 (get-buffer-create merge-buffer-name))))
633 (if output-file
634 (concat "Output to file: " output-file)
635 (concat "Output to buffer: " (buffer-name merge-buffer))))
638 (setq emerge-difference-list (emerge-make-diff-list file-A file-B))
650 (defun emerge-make-diff-list (file-A file-B)
658 (emerge-protect-metachars file-A)
659 (emerge-protect-metachars file-B))
718 ;;; Top-level and setup functions for three-file mode.
720 (defun emerge-files-with-ancestor-internal (file-A file-B file-ancestor
722 output-file)
723 (if (not (file-readable-p file-A))
724 (error "File `%s' does not exist or is not readable" file-A))
725 (if (not (file-readable-p file-B))
726 (error "File `%s' does not exist or is not readable" file-B))
727 (if (not (file-readable-p file-ancestor))
728 (error "File `%s' does not exist or is not readable" file-ancestor))
729 (let ((buffer-A (find-file-noselect file-A))
730 (buffer-B (find-file-noselect file-B))
731 (buffer-ancestor (find-file-noselect file-ancestor)))
733 (setq emerge-last-dir-A (file-name-directory file-A))
734 (setq emerge-last-dir-B (file-name-directory file-B))
735 (setq emerge-last-dir-ancestor (file-name-directory file-ancestor))
736 (if output-file
737 (setq emerge-last-dir-output (file-name-directory output-file)))
742 (let ((temp (file-local-copy file-A)))
743 (if temp
744 (setq file-A temp
746 (cons `(lambda () (delete-file ,file-A))
748 ;; Verify that the file matches the buffer
749 (emerge-verify-file-buffer))))
753 (let ((temp (file-local-copy file-B)))
754 (if temp
755 (setq file-B temp
757 (cons `(lambda () (delete-file ,file-B))
759 ;; Verify that the file matches the buffer
760 (emerge-verify-file-buffer))))
764 (let ((temp (file-local-copy file-ancestor)))
765 (if temp
766 (setq file-ancestor temp
768 (cons `(lambda () (delete-file ,file-ancestor))
770 ;; Verify that the file matches the buffer
771 (emerge-verify-file-buffer))))
772 (emerge-setup-with-ancestor buffer-A file-A buffer-B file-B
773 buffer-ancestor file-ancestor
774 startup-hooks quit-hooks output-file)))
777 (defun emerge-setup-with-ancestor (buffer-A file-A buffer-B file-B
778 buffer-ancestor file-ancestor
780 output-file)
781 (setq file-A (expand-file-name file-A))
782 (setq file-B (expand-file-name file-B))
783 (setq file-ancestor (expand-file-name file-ancestor))
784 (setq output-file (and output-file (expand-file-name output-file)))
785 (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*"))
790 (get-buffer-create merge-buffer-name))))
802 (if output-file
803 (concat "Output to file: " output-file)
804 (concat "Output to buffer: " (buffer-name merge-buffer))))
808 (emerge-make-diff3-list file-A file-B file-ancestor))
821 (defun emerge-make-diff3-list (file-A file-B file-ancestor)
829 (emerge-protect-metachars file-A)
830 (emerge-protect-metachars file-ancestor)
831 (emerge-protect-metachars file-B))
863 (defun emerge-get-diff3-group (file)
870 (concat "^" file ":\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\\([ac]\\)$"))
893 (defun emerge-files (arg file-A file-B file-out &optional startup-hooks
899 (setq f (emerge-read-file-name "File A to merge" emerge-last-dir-A
901 (emerge-read-file-name "File B to merge" emerge-last-dir-B nil f t)
903 (emerge-read-file-name "Output file" emerge-last-dir-output
905 (if file-out
906 (add-hook 'quit-hooks `(lambda () (emerge-files-exit ,file-out))))
908 file-A file-B startup-hooks
910 file-out))
913 (defun emerge-files-with-ancestor (arg file-A file-B file-ancestor file-out
915 "Run Emerge on two files, giving another file as the ancestor."
919 (setq f (emerge-read-file-name "File A to merge" emerge-last-dir-A
921 (emerge-read-file-name "File B to merge" emerge-last-dir-B nil f t)
922 (emerge-read-file-name "Ancestor file" emerge-last-dir-ancestor
925 (emerge-read-file-name "Output file" emerge-last-dir-output
927 (if file-out
928 (add-hook 'quit-hooks `(lambda () (emerge-files-exit ,file-out))))
930 file-A file-B file-ancestor startup-hooks
932 file-out))
934 ;; Write the merge buffer out in place of the file the A buffer is visiting.
935 (defun emerge-files-exit (file-out)
938 (emerge-write-and-delete file-out)))
946 (let ((emerge-file-A (emerge-make-temp-file "A"))
947 (emerge-file-B (emerge-make-temp-file "B")))
950 (write-region (point-min) (point-max) emerge-file-A nil 'no-message))
953 (write-region (point-min) (point-max) emerge-file-B nil 'no-message))
954 (emerge-setup (get-buffer buffer-A) emerge-file-A
955 (get-buffer buffer-B) emerge-file-B
957 (delete-file ,emerge-file-A)
958 (delete-file ,emerge-file-B))
970 (let ((emerge-file-A (emerge-make-temp-file "A"))
971 (emerge-file-B (emerge-make-temp-file "B"))
972 (emerge-file-ancestor (emerge-make-temp-file "anc")))
975 (write-region (point-min) (point-max) emerge-file-A nil 'no-message))
978 (write-region (point-min) (point-max) emerge-file-B nil 'no-message))
981 (write-region (point-min) (point-max) emerge-file-ancestor nil
983 (emerge-setup-with-ancestor (get-buffer buffer-A) emerge-file-A
984 (get-buffer buffer-B) emerge-file-B
986 emerge-file-ancestor
988 (delete-file ,emerge-file-A)
989 (delete-file ,emerge-file-B)
990 (delete-file
991 ,emerge-file-ancestor))
1000 (let ((file-a (nth 0 command-line-args-left))
1001 (file-b (nth 1 command-line-args-left))
1002 (file-out (nth 2 command-line-args-left)))
1005 file-a file-b nil
1006 (list `(lambda () (emerge-command-exit ,file-out))))))
1010 (let (file-a file-b file-anc file-out)
1013 ;; arguments are "-a ancestor file-a file-b file-out"
1015 (setq file-a (nth 2 command-line-args-left))
1016 (setq file-b (nth 3 command-line-args-left))
1017 (setq file-anc (nth 1 command-line-args-left))
1018 (setq file-out (nth 4 command-line-args-left))
1020 ;; arguments are "file-a file-b ancestor file-out"
1021 (setq file-a (nth 0 command-line-args-left))
1022 (setq file-b (nth 1 command-line-args-left))
1023 (setq file-anc (nth 2 command-line-args-left))
1024 (setq file-out (nth 3 command-line-args-left))
1027 file-a file-b file-anc nil
1028 (list `(lambda () (emerge-command-exit ,file-out))))))
1030 (defun emerge-command-exit (file-out)
1031 (emerge-write-and-delete file-out)
1037 (defun emerge-files-remote (file-a file-b file-out)
1038 (setq emerge-file-out file-out)
1040 file-a file-b nil
1041 (list `(lambda () (emerge-remote-exit ,file-out ',emerge-exit-func)))
1042 file-out)
1046 (defun emerge-files-with-ancestor-remote (file-a file-b file-anc file-out)
1047 (setq emerge-file-out file-out)
1049 file-a file-b file-anc nil
1050 (list `(lambda () (emerge-remote-exit ,file-out ',emerge-exit-func)))
1051 file-out)
1054 (defun emerge-remote-exit (file-out emerge-exit-func)
1055 (emerge-write-and-delete file-out)
1062 (defun emerge-revisions (arg file revision-A revision-B
1064 "Emerge two RCS revisions of a file."
1067 (read-file-name "File to merge: " nil nil 'confirm)
1073 file revision-A revision-B startup-hooks
1077 ,(format "%s %s" emerge-rcs-ci-program file)))
1082 (defun emerge-revisions-with-ancestor (arg file revision-A
1086 "Emerge two RCS revisions of a file, with another revision as ancestor."
1089 (read-file-name "File to merge: " nil nil 'confirm)
1097 file revision-A revision-B ancestor startup-hooks
1102 ,(format "%s %s" emerge-rcs-ci-program file)))
1106 (defun emerge-revisions-internal (file revision-A revision-B &optional
1107 startup-hooks quit-hooks output-file)
1108 (let ((buffer-A (get-buffer-create (format "%s,%s" file revision-A)))
1109 (buffer-B (get-buffer-create (format "%s,%s" file revision-B)))
1110 (emerge-file-A (emerge-make-temp-file "A"))
1111 (emerge-file-B (emerge-make-temp-file "B")))
1117 (format "%s -q -p%s %s" emerge-rcs-co-program revision-A file)
1119 (write-region (point-min) (point-max) emerge-file-A nil 'no-message)
1125 (format "%s -q -p%s %s" emerge-rcs-co-program revision-B file)
1127 (write-region (point-min) (point-max) emerge-file-B nil 'no-message)
1130 (emerge-setup buffer-A emerge-file-A
1131 buffer-B emerge-file-B
1133 (delete-file ,emerge-file-A)
1134 (delete-file ,emerge-file-B))
1136 (cons `(lambda () (emerge-files-exit ,file))
1140 (defun emerge-revision-with-ancestor-internal (file revision-A revision-B
1143 quit-hooks output-file)
1144 (let ((buffer-A (get-buffer-create (format "%s,%s" file revision-A)))
1145 (buffer-B (get-buffer-create (format "%s,%s" file revision-B)))
1146 (buffer-ancestor (get-buffer-create (format "%s,%s" file ancestor)))
1147 (emerge-file-A (emerge-make-temp-file "A"))
1148 (emerge-file-B (emerge-make-temp-file "B"))
1149 (emerge-ancestor (emerge-make-temp-file "ancestor")))
1156 revision-A file)
1158 (write-region (point-min) (point-max) emerge-file-A nil 'no-message)
1164 (format "%s -q -p%s %s" emerge-rcs-co-program revision-B file)
1166 (write-region (point-min) (point-max) emerge-file-B nil 'no-message)
1172 (format "%s -q -p%s %s" emerge-rcs-co-program ancestor file)
1178 buffer-A emerge-file-A buffer-B emerge-file-B
1181 (delete-file ,emerge-file-A)
1182 (delete-file ,emerge-file-B)
1183 (delete-file ,emerge-ancestor))
1185 (cons `(lambda () (emerge-files-exit ,file))
1187 output-file)))
1189 ;;; Function to start Emerge based on a line in a file
1200 In addition, if only one of `a=file' or `b=file' is present, and `output=file'
1202 If `emerge-execute-line-deletions' is non-nil and `ancestor=file' is present,
1203 it is assumed that the file in question has been deleted, and it is
1204 not copied to the output file.
1205 Otherwise, the A or B file present is copied to the output file."
1207 (let (file-A file-B file-ancestor file-out
1225 (file (buffer-substring (match-beginning 2) (match-end 2))))
1231 (if file-A
1233 (setq file-A file))
1235 (if file-B
1237 (setq file-B file))
1239 (if file-ancestor
1241 (setq file-ancestor file))
1243 (if file-out
1245 (setq file-out file))
1250 ;; Make sure that file-A and file-B are present
1251 (if (not (or (and file-A file-B) file-out))
1253 (if (not (or file-A file-B))
1261 ((and file-A file-B file-ancestor)
1262 (message "Merging %s and %s..." file-A file-B)
1263 (emerge-files-with-ancestor (not (not file-out)) file-A file-B
1264 file-ancestor file-out
1272 ((and file-A file-B)
1273 (message "Merging %s and %s..." file-A file-B)
1274 (emerge-files (not (not file-out)) file-A file-B file-out
1281 ;; There is an output file (or there would have been an error above),
1282 ;; but only one input file.
1283 ;; The file appears to have been deleted in one version; do nothing.
1284 ((and file-ancestor emerge-execute-line-deletions)
1286 ;; The file should be copied from the version that contains it
1287 (t (let ((input-file (or file-A file-B)))
1289 (copy-file input-file file-out)
1290 (message "%s copied to %s." input-file file-out))))))
1303 (read-file-name "A directory: " nil nil 'confirm)
1304 (read-file-name "B directory: " nil nil 'confirm)
1305 (read-file-name "Ancestor directory (null for none): " nil nil 'confirm)
1306 (read-file-name "Output directory (null for none): " nil nil 'confirm)))
1316 (setq a-dir (expand-file-name a-dir))
1319 (setq b-dir (expand-file-name b-dir))
1324 (setq ancestor-dir (expand-file-name ancestor-dir))
1329 (setq output-dir (expand-file-name output-dir))
1403 (buffer-name emerge-merge-buffer))
1430 ;; Suppress write-file and save-buffer
1431 (substitute-key-definition 'write-file
1432 'emerge-query-write-file
1437 (define-key emerge-edit-keymap [remap write-file] 'emerge-query-write-file)
1558 ;; Process the local-variables list at the end of the merged file, if
1569 (defun emerge-write-and-delete (file-out)
1580 ;; Write merge buffer to file
1581 (and file-out
1582 (write-file file-out)))
1870 flags of the merged file buffers, restores the local keymap of the merge
2150 (defun emerge-file-names ()
2155 (let ((temp-buffer-show-function
2160 (with-output-to-temp-buffer "*Help*"
2162 (if buffer-file-name
2165 (princ buffer-file-name))
2168 (princ (buffer-name))))
2171 (if buffer-file-name
2174 (princ buffer-file-name))
2177 (princ (buffer-name))))
2181 (if buffer-file-name
2183 (princ "Ancestor file is: ")
2184 (princ buffer-file-name))
2187 (princ (buffer-name))))
2502 (let (temp)
2503 (setq temp (save-excursion
2509 (setq temp (- temp emerge-before-flag-lines)))
2511 (setq temp (- temp emerge-after-flag-lines)))))
2512 temp))
2775 ;; Read a file name, handling all of the various defaulting rules.
2777 (defun emerge-read-file-name (prompt alternative-default-dir default-file
2778 A-file must-match)
2784 ;; If default-file is set, it should be used as the default value.
2785 ;; If A-file is set, and its directory is different from
2787 ;; the default file should be the last part of A-file in the default
2788 ;; directory. (Overriding default-file.)
2790 ;; If this is not the A-file argument (shown by non-nil A-file), and
2793 ;; A-file,
2794 ;; then make the default file have the same name as the A-file, but in
2797 A-file
2800 (file-name-directory A-file))))
2801 (read-file-name (format "%s (default %s): "
2802 prompt (file-name-nondirectory A-file))
2805 (file-name-nondirectory A-file))
2807 ;; If there is a default file, use it.
2808 (default-file
2809 (read-file-name (format "%s (default %s): " prompt default-file)
2815 default-file (and must-match 'confirm)))
2817 (read-file-name (concat prompt ": ")
2869 ;; Construct a unique buffer name.
2872 (defun emerge-unique-buffer-name (prefix suffix)
2911 ;; Make a temporary file that only we have access to.
2912 ;; PREFIX is appended to emerge-temp-file-prefix to make the filename prefix.
2913 (defun emerge-make-temp-file (prefix)
2914 (let (f (old-modes (default-file-modes)))
2917 (set-default-file-modes emerge-temp-file-mode)
2918 (setq f (make-temp-file (concat emerge-temp-file-prefix prefix))))
2919 (set-default-file-modes old-modes))
2924 (defun emerge-query-write-file ()
2926 If answer is yes, call `write-file' to do so. See `emerge-query-and-call'
2929 (emerge-query-and-call 'write-file))
2961 ;; Make sure the current buffer (for a file) has the same contents as the
2962 ;; file on disk, and attempt to remedy the situation if not.
2965 (defun emerge-verify-file-buffer ()
2966 ;; First check if the file has been modified since the buffer visited it.
2967 (if (verify-visited-file-modtime (current-buffer))
2970 (if (yes-or-no-p (format "Save file %s? " buffer-file-name))
2972 (error "Buffer out of sync for file %s" buffer-file-name))
2977 (error "Buffer out of sync for file %s" buffer-file-name)
2979 (if (yes-or-no-p (format "Revert file %s? " buffer-file-name))
2981 (error "Buffer out of sync for file %s" buffer-file-name)))))
3014 ;; (with-output-to-temp-buffer "*Help*"
3015 ;; (princ mode-name)
3102 ;; Show the name of the file in the buffer.
3103 (defun emerge-show-file-name ()
3104 "Displays the name of the file loaded into the current buffer.
3105 If the name won't fit on one line, the minibuffer is expanded to hold it,
3109 (let ((name (buffer-file-name)))
3110 (or name
3111 (setq name "Buffer has no file name."))
3117 (insert name)
3128 ;; Improved auto-save file names.
3129 ;; This function fixes many problems with the standard auto-save file names:
3130 ;; Auto-save files for non-file buffers get put in the default directory
3132 ;; Auto-save files for file buffers get put in the directory of the file,
3134 ;; Auto-save files for non-file buffers don't use the process id, so if a
3138 ;; (fset 'make-auto-save-file-name
3139 ;; (symbol-function 'emerge-make-auto-save-file-name))
3140 (defun emerge-make-auto-save-file-name ()
3141 "Return file name to use for auto-saves of current buffer.
3142 Does not consider `auto-save-visited-file-name';
3145 See also `auto-save-file-name-p'."
3146 (if buffer-file-name
3147 ;; if buffer has a file, try the format <file directory>/#<file name>#
3148 (let ((f (concat (file-name-directory buffer-file-name)
3150 (file-name-nondirectory buffer-file-name)
3152 (if (file-writable-p f)
3153 ;; the file is writable, so use it
3155 ;; the file isn't writable, so use the format
3156 ;; ~/#&<file name>&<hash of directory>#
3159 (file-name-nondirectory buffer-file-name)
3162 (file-name-directory buffer-file-name))
3164 ;; if buffer has no file, use the format ~/#%<buffer name>%<process id>#
3165 (expand-file-name (concat (getenv "HOME")
3168 (emerge-unslashify-name (buffer-name))
3170 (make-temp-name "")
3173 ;; Hash a string into five characters more-or-less suitable for use in a file
3174 ;; name. (Allowed characters are ! through ~, except /.)
3192 (defun emerge-unslashify-name (s)