- Timestamp:
- May 20, 2007, 12:49:21 AM (18 years ago)
- Location:
- branches/ide-1.0/ccl/hemlock/src
- Files:
-
- 3 edited
-
filecoms.lisp (modified) (5 diffs)
-
listener.lisp (modified) (1 diff)
-
macros.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/ide-1.0/ccl/hemlock/src/filecoms.lisp
r810 r6572 842 842 (message "Buffer marked as unmodified.")) 843 843 844 (defcommand "Check Buffer Modified" (p) 845 "Say whether the buffer is modified or not." 846 "Say whether the current buffer is modified or not." 847 (declare (ignore p)) 848 (clear-echo-area) 849 (message "Buffer ~S ~:[is not~;is~] modified." 850 (buffer-name (current-buffer)) (buffer-modified (current-buffer)))) 844 851 845 852 846 (defcommand "Set Buffer Read-Only" (p) … … 868 862 869 863 870 ;;; TODO: If this is true, it is possible to make Hemlock unusable by 871 ;;; killing last buffer and selecting Echo Area as the new buffer. 872 (defhvar "Ask for New Buffer" 873 "If true, user is prompted for new buffer after current buffer is 874 deleted. If false then previous buffer is selected automatically." 875 :value nil) 876 877 878 (defcommand "Kill Buffer" (p &optional buffer-name) 879 "Prompts for a buffer to delete. 880 If the buffer is modified, then let the user save the file before doing so. 881 When deleting the current buffer, prompts for a new buffer to select. If 882 a buffer other than the current one is deleted then any windows into it 883 are deleted." 884 "Delete buffer Buffer-Name, doing sensible things if the buffer is displayed 885 or current." 886 (declare (ignore p)) 887 (let ((buffer (if buffer-name 888 (getstring buffer-name *buffer-names*) 889 (prompt-for-buffer :prompt "Kill Buffer: " 890 :default (current-buffer))))) 891 (unless buffer 892 (editor-error "No buffer named ~S" buffer-name)) 893 (when (and (buffer-modified buffer) 894 (prompt-for-y-or-n :prompt "Save it first? ")) 895 (save-file-command nil buffer)) 896 (if (eq buffer (current-buffer)) 897 (let* ((previous (or (previous-buffer) 898 (editor-error "Cannot kill last buffer."))) 899 (new (if (value ask-for-new-buffer) 900 (prompt-for-buffer 901 :prompt "New Buffer: " 902 :default previous 903 :help "Buffer to change to after the current one is killed.") 904 previous))) 905 (when (eq new buffer) 906 (editor-error "You must select a different buffer.")) 907 (dolist (w (buffer-windows buffer)) 908 (setf (window-buffer w) new)) 909 (setf (current-buffer) new)) 910 (dolist (w (buffer-windows buffer)) 911 (delete-window w))) 912 (delete-buffer buffer))) 913 914 915 (defcommand "Rename Buffer" (p) 916 "Change the current buffer's name. 917 The name, which is prompted for, defaults to the name of the associated 918 file." 919 "Change the name of the current buffer." 920 (declare (ignore p)) 921 (let* ((buf (current-buffer)) 922 (pn (buffer-pathname buf)) 923 (name (if pn (pathname-to-buffer-name pn) (buffer-name buf))) 924 (new (prompt-for-string :prompt "New Name: " 925 :help "Give a new name for the current buffer" 926 :default name))) 927 (multiple-value-bind (entry foundp) (getstring new *buffer-names*) 928 (cond ((or (not foundp) (eq entry buf)) 929 (setf (buffer-name buf) new)) 930 (t (editor-error "Name ~S already in use." new)))))) 931 932 933 (defcommand "Insert Buffer" (p) 934 "Insert the contents of a buffer. 935 The name of the buffer to insert is prompted for." 936 "Prompt for a buffer to insert at the point." 937 (declare (ignore p)) 938 (let ((point (current-point)) 939 (region (buffer-region (prompt-for-buffer 940 :default (previous-buffer) 941 :help 942 "Type the name of a buffer to insert.")))) 943 ;; 944 ;; start and end will be deleted by undo stuff 945 (let ((save (region (copy-mark point :right-inserting) 946 (copy-mark point :left-inserting)))) 947 (push-buffer-mark (copy-mark point)) 948 (insert-region point region) 949 (make-region-undo :delete "Insert Buffer" save)))) 950 951 952 953 954 ;;;; File utility commands: 955 956 (defcommand "Directory" (p) 957 "Do a directory into a pop-up window. If an argument is supplied, then 958 dot files are listed too (as with ls -a). Prompts for a pathname which 959 may contain wildcards in the name and type." 960 "Do a directory into a pop-up window." 961 (let* ((dpn (value pathname-defaults)) 962 (pn (prompt-for-file 963 :prompt "Directory: " 964 :help "Pathname to do directory on." 965 :default (make-pathname :device (pathname-device dpn) 966 :directory (pathname-directory dpn)) 967 :must-exist nil))) 968 (setf (value pathname-defaults) (merge-pathnames pn dpn)) 969 (with-pop-up-display (s) 970 (print-directory pn s :all p)))) 971 972 (defcommand "Verbose Directory" (p) 973 "Do a directory into a pop-up window. If an argument is supplied, then 974 dot files are listed too (as with ls -a). Prompts for a pathname which 975 may contain wildcards in the name and type." 976 "Do a directory into a pop-up window." 977 (let* ((dpn (value pathname-defaults)) 978 (pn (prompt-for-file 979 :prompt "Verbose Directory: " 980 :help "Pathname to do directory on." 981 :default (make-pathname :device (pathname-device dpn) 982 :directory (pathname-directory dpn)) 983 :must-exist nil))) 984 (setf (value pathname-defaults) (merge-pathnames pn dpn)) 985 (with-pop-up-display (s) 986 (print-directory pn s :verbose t :all p)))) 987 988 989 990 991 ;;;; Change log stuff: 992 993 (define-file-option "Log" (buffer value) 994 (defhvar "Log File Name" 995 "The name of the file for the change log for the file in this buffer." 996 :buffer buffer :value value)) 997 998 (defhvar "Log Entry Template" 999 "The format string used to generate the template for a change-log entry. 1000 Three arguments are given: the file, the date (create if available, now 1001 otherwise) and the file author, or NIL if not available. The last \"@\" 1002 is deleted and the point placed where it was." 1003 :value "~A, ~A, Edit by ~:[???~;~:*~:(~A~)~].~% @~2%") 1004 1005 (defmode "Log" 1006 :major-p t 1007 :setup-function 1008 #'(lambda (buffer) 1009 (setf (buffer-minor-mode buffer "Fill") t)) 1010 :cleanup-function 1011 #'(lambda (buffer) 1012 (setf (buffer-minor-mode buffer "Fill") nil))) 1013 1014 (defhvar "Fill Prefix" "The fill prefix in Log mode." 1015 :value " " :mode "Log") 1016 1017 (define-file-type-hook ("log") (buffer type) 1018 (declare (ignore type)) 1019 (setf (buffer-major-mode buffer) "Log")) 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 1020 889 1021 890 (defun universal-time-to-string (ut) … … 1029 898 hour min sec))) 1030 899 1031 (defvar *back-to-@-pattern* (new-search-pattern :character :backward #\@)) 1032 (defcommand "Log Change" (p) 1033 "Make an entry in the change-log file for this buffer. 1034 Saves the file in the current buffer if it is modified, then finds the file 1035 specified in the \"Log\" file option, adds the template for a change-log 1036 entry at the beginning, then does a recursive edit, saving the log file on 1037 exit." 1038 "Find the change-log file as specified by \"Log File Name\" and edit it." 1039 (declare (ignore p)) 1040 (unless (hemlock-bound-p 'log-file-name) 1041 (editor-error "No log file defined.")) 1042 (let* ((buffer (current-buffer)) 1043 (pathname (buffer-pathname buffer))) 1044 (when (or (buffer-modified buffer) (null pathname)) 1045 (save-file-command ())) 1046 (unwind-protect 1047 (progn 1048 (find-file-command nil (merge-pathnames 1049 (value log-file-name) 1050 (buffer-default-pathname buffer))) 1051 (let ((point (current-point))) 1052 (buffer-start point) 1053 (with-output-to-mark (s point :full) 1054 (format s (value log-entry-template) 1055 (namestring pathname) 1056 (universal-time-to-string 1057 (or (file-write-date pathname) 1058 (get-universal-time))) 1059 (file-author pathname))) 1060 (when (find-pattern point *back-to-@-pattern*) 1061 (delete-characters point 1))) 1062 (do-recursive-edit) 1063 (when (buffer-modified (current-buffer)) (save-file-command ()))) 1064 (if (member buffer *buffer-list* :test #'eq) 1065 (change-to-buffer buffer) 1066 (editor-error "Old buffer has been deleted."))))) 900 1067 901 1068 902 … … 1071 905 ;;;; Window hacking commands: 1072 906 1073 (defcommand "Next Window" (p) 1074 "Change the current window to be the next window and the current buffer 1075 to be it's buffer." 1076 "Go to the next window. 1077 If the next window is the bottom window then wrap around to the top window." 1078 (declare (ignore p)) 1079 (let* ((next (next-window (current-window))) 1080 (buffer (window-buffer next))) 1081 (setf (current-buffer) buffer (current-window) next))) 1082 1083 (defcommand "Previous Window" (p) 1084 "Change the current window to be the previous window and the current buffer 1085 to be it's buffer." 1086 "Go to the previous window. 1087 If the Previous window is the top window then wrap around to the bottom." 1088 (declare (ignore p)) 1089 (let* ((previous (previous-window (current-window))) 1090 (buffer (window-buffer previous))) 1091 (setf (current-buffer) buffer (current-window) previous))) 907 1092 908 1093 909 (defcommand "Split Window" (p) … … 1102 918 (setf (current-window) new))) 1103 919 1104 (defcommand "New Window" (p) 1105 "Make a new window and go to it. 1106 The window will display the same buffer as the current one." 1107 "Create a new window which displays starting at the same place 1108 as the current window." 1109 (declare (ignore p)) 1110 (let ((new (make-window (window-display-start (current-window)) 1111 :ask-user t))) 1112 (unless new (editor-error "Could not make a new window.")) 1113 (setf (current-window) new))) 1114 1115 (defcommand "Delete Window" (p) 1116 "Delete the current window, going to the previous window." 1117 "Delete the window we are in, going to the previous window." 1118 (declare (ignore p)) 1119 (when (= (length *window-list*) 2) 1120 (editor-error "Cannot delete only window.")) 1121 (let ((window (current-window))) 1122 (previous-window-command nil) 1123 (delete-window window))) 1124 1125 (defcommand "Line to Top of Window" (p) 1126 "Move current line to top of window." 1127 "Move current line to top of window." 1128 (declare (ignore p)) 1129 (with-mark ((mark (current-point))) 1130 (move-mark (window-display-start (current-window)) (line-start mark)))) 1131 1132 (defcommand "Delete Next Window" (p) 1133 "Deletes the next window on display." 1134 "Deletes then next window on display." 1135 (declare (ignore p)) 1136 (if (<= (length *window-list*) 2) 1137 (editor-error "Cannot delete only window") 1138 (delete-window (next-window (current-window))))) 1139 1140 (defcommand "Go to One Window" (p) 1141 "Deletes all windows leaving one with the \"Default Initial Window X\", 1142 \"Default Initial Window Y\", \"Default Initial Window Width\", and 1143 \"Default Initial Window Height\"." 1144 "Deletes all windows leaving one with the \"Default Initial Window X\", 1145 \"Default Initial Window Y\", \"Default Initial Window Width\", and 1146 \"Default Initial Window Height\"." 1147 (declare (ignore p)) 1148 (let ((win (make-window (window-display-start (current-window)) 1149 :ask-user t 1150 :x (value default-initial-window-x) 1151 :y (value default-initial-window-y) 1152 :width (value default-initial-window-width) 1153 :height (value default-initial-window-height)))) 1154 (setf (current-window) win) 1155 (dolist (w *window-list*) 1156 (unless (or (eq w win) 1157 (eq w *echo-area-window*)) 1158 (delete-window w))))) 1159 1160 (defcommand "Line to Center of Window" (p) 1161 "Moves current line to the center of the window." 1162 "Moves current line to the center of the window." 1163 (declare (ignore p)) 1164 (center-window (current-window) (current-point))) 920 921 922 923 924 -
branches/ide-1.0/ccl/hemlock/src/listener.lisp
r2093 r6572 667 667 (in-lisp (compile-file (namestring pn) #+cmu :error-file #+cmu nil)))))))) 668 668 669 (defcommand "Editor Compile Group" (p) 670 "Compile each file in the current group which needs it in the editor Lisp. 671 If a file has type LISP and there is a curresponding file with type 672 FASL which has been written less recently (or it doesn't exit), then 673 the file is compiled, with error output directed to the \"Compiler Warnings\" 674 buffer. If a prefix argument is provided, then all the files are compiled. 675 All modified files are saved beforehand." 676 "Do a Compile-File in each file in the current group that seems to need it 677 in the editor Lisp." 678 (save-all-files-command ()) 679 (unless *active-file-group* (editor-error "No active file group.")) 680 (dolist (file *active-file-group*) 681 (when (string-equal (pathname-type file) "lisp") 682 (let ((tn (probe-file file))) 683 (cond ((not tn) 684 (message "File ~A not found." (namestring file))) 685 ((older-or-non-existent-fasl-p tn p) 686 (with-output-to-window (*error-output* "Compiler Warnings") 687 (in-lisp (compile-file (namestring tn) #+cmu :error-file #+cmu nil))))))))) 688 689 (defcommand "List Compile Group" (p) 690 "List any files that would be compiled by \"Compile Group\". All Modified 691 files are saved before checking to generate a consistent list." 692 "Do a Compile-File in each file in the current group that seems to need it." 693 (declare (ignore p)) 694 (save-all-files-command ()) 695 (unless *active-file-group* (editor-error "No active file group.")) 696 (with-pop-up-display (s) 697 (write-line "\"Compile Group\" would compile the following files:" s) 698 (force-output s) 699 (dolist (file *active-file-group*) 700 (when (string-equal (pathname-type file) "lisp") 701 (let ((tn (probe-file file))) 702 (cond ((not tn) 703 (format s "File ~A not found.~%" (namestring file))) 704 ((older-or-non-existent-fasl-p tn) 705 (write-line (namestring tn) s))) 706 (force-output s)))))) 707 708 (defhvar "Load Pathname Defaults" 709 "The default pathname used by the load command.") 710 711 (defcommand "Editor Load File" (p) 712 "Prompt for a file to load into Editor Lisp." 713 "Prompt for a file to load into the Editor Lisp." 714 (declare (ignore p)) 715 (let ((name (truename (prompt-for-file 716 :default 717 (or (value load-pathname-defaults) 718 (buffer-default-pathname (current-buffer))) 719 :prompt "Editor file to load: " 720 :help "The name of the file to load")))) 721 (setv load-pathname-defaults name) 722 (in-lisp (load name)))) 669 670 671 723 672 724 673 -
branches/ide-1.0/ccl/hemlock/src/macros.lisp
r880 r6572 318 318 |# 319 319 320 (defmacro use-buffer (buffer &body forms) 321 "Use-Buffer Buffer {Form}* 322 Has The effect of making Buffer the current buffer during the evaluation 323 of the Forms. For restrictions see the manual." 324 (let ((gensym (gensym))) 325 `(let ((,gensym *current-buffer*) 326 (*current-buffer* ,buffer)) 327 (unwind-protect 328 (progn 329 (use-buffer-set-up ,gensym) 330 ,@forms) 331 (use-buffer-clean-up ,gensym))))) 320 332 321 333 322
Note:
See TracChangeset
for help on using the changeset viewer.
