diff lisp/simple.el @ 502:7039e6323819

[xemacs-hg @ 2001-05-04 22:41:46 by ben] ----------------------- byte-comp warning fixes ----------------- New functions for cleanly eliminating byte-compiler warnings. Their definitions require no changes at all in bytecomp.el, meaning that any package that wants to use them and be compatible with older versions of XEmacs need only copy the code and rename the functions (i.e. prefix them with the package name). Eliminate byte-compiler warnings using the new functions in bytecomp-runtime.el. Move coding-system-put,get,category, since they're not Mule-specific and are used in prefer-coding-system. font.el was incredibly ugly. Clean it up. Avoid using defsubst for any exported functions, to avoid possible compatibility problems if we later change the internal interface. (It happened before, with face accessors, between 19.8 and 19.9). Fix tons of warnings. Clean up (new function gpm-is-supported-p eliminates duplicate code in gpm-create/delete-device-hook) and eliminate warnings. ---------- make byte-recompile-directory work in the --------- core `lisp' dir, even in the absence of a Mule XEmacs (i.e. make it skip the Mule files rather than trying to compile them). now you should be able to do `touch *.el' in the `lisp' dir, then M-x byte-recompile-directory, and get no warnings. Avoid trying to compile Mule files in byte-recompile-directory when we're not in a Mule XEmacs, since we're highly likely to get syntax errors. Add a coding-system cookie to all Mule files so that byte-recompile-directory ignores them. Magic cookie function moved to files.el from code-files.el (for use by bytecomp even in a non-coding-system XEmacs), and changed names and semantics for use by bytecomp. NOTE: IMO this is an internal function that we can change as we like (and there is absolutely no code anywhere else using the function). ---------------- GUI improvements: menus, help ------------------- Rearrange order of keymap declarations to be alphabetical. Improve help on help to include all bindings, and group by category. Add bindings for new Info commands. Remove warnings. Use command-hyper-apropos in place of command-apropos. Add a function to do the equivalent of command-apropos. Evals its help-text argument so you can put expressions there. Used now by help-for-help. Add binding to continue text searches. Expand index searches to work over multiple info documents. Add commands to search text/index in User and Lispref. Add new entry, "Uncomment Region" (parallels "Comment Out Region"). Redo Help menu; add bindings for new Info commands to search the index or text of the User and Lispref manuals. Add command for mark-paragraph, activate-region. Make Edit->R accelerator be rectangle, not register (more commonly used), and put rectangle first. Fix the Edit Init File entry to never load the .elc file. Simplify the default-popup-menu. Add Cmds->Tabs menu. Use kp-left not kp_left, etc. ---------------- Miscellaneous bug fixes/cleanup ------------------- byte-compiler-options: Correct doc string. easy-menu-do-define: fix extra quote. fill-paragraph-or-region:Rewrite to be more correct -- use call-interactively so that we always get exactly the same behavior as if the functions were called directly. No need to fiddle with zmacs-region-stays, now that bogus clearing of it (2001-04-28 src/ChangeLog) is removed. Put dialog titles back in -- this time correctly. Fix various other problems with leaks and such. key-sequence-list-description: Clean up fun to always correctly canonicalize. Clean up Kinsoku comments, synch comment-region with FSF 20.7. * simple.el (region-exists-p): * simple.el (region-active-p): Add comment about which one is correct to use in menu specs. * sound.el (load-sound-file): Minor code clean up. * startup.el: * startup.el (command-line-early): * startup.el (initial-scratch-message): Comment changes. Add info about sample.init.el to splash screen. Improve initial-scratch-message and clarify purpose of Scratch buffer. Fix byte-compile warning. ------------------------ Added features ------------------------- Add new variable to control whether etags checks all parent directories for tag files. (On by default.) * hash-table.el: New file, useful utility functions. * dumped-lisp.el (preloaded-file-list): Dump hash-table.el. ------------ notable bug fix: Windows event code -------------- Get critical quit working. ------------ notable bug fix and new feature: regex code -------------- Shy groups were implemented in a horrible, half-assed way that would cause them to screw up regex searching in most cases. Fixed to work correctly. Also extended back-reference syntax past 9. Only is recognized as such if there are at least that many non-shy groups; and optionally will warn about such uses, to catch old code that might be using them differently. (Added variable to control this in search.c -- `warn-about-possibly-incompatible-back- references', on by default for the moment. Declared in lisp.h. ---------------- process/SIGIO improvements ------------------- define USE_GETADDRINFO to replace more complex conditional, and use it. the code conditionalized on this in unix_open_network_stream had *serious* problems handling errors. it's now fixed, and major amounts of duplicate code between the two versions were combined. don't disable SIGIO and other interrupts unless CONNECT_NEEDS_SLOWED_INTERRUPTS is defined -- don't penalize OS's without bugs. similarly for a freebsd bug that was affecting all OS's. * s\ultrix.h: define CONNECT_NEEDS_SLOWED_INTERRUPTS, since that's the OS mentioned as having a kernel bug. * sysdep.c (request_sigio_on_device): * sysdep.c (unrequest_sigio_on_device): fix SIGIO problems on Linux. add check for O_ASYNC in case it's defined and FASYNC isn't. add comment about other ways to do SIGIO on Linux. * callproc.c (Fold_call_process_internal): * process.c (Fstart_process_internal): Deal with the possibility that `default-directory' doesn't have terminating slash. Correct comments about vfork. ---------------- Miscellaneous bug fixes/cleanup ------------------- * callint.c (Finteractive): Add lots of documentation -- exactly what the Lisp equivalents of all the interactive specs are. * console.h (struct console): change type of quit_char to Emchar. * event-msw.c (lstream_type_create_mswindows_selectable): spacing change. Eliminate events-mod.h and combine into events.h. * emacs.c: * emacs.c (make_arg_list_1): * emacs.c (main_1): A couple of char->Extbyte changes, add a comment. * glyphs-msw.c: Correct indentation of function defns to not exceed 80 cols. Try (sort of) to fix some code that sets the colors of the progress gauge. (Commented out) * keymap.c (syms_of_keymap): use DEFSYMBOL. * process.c (read_process_output): No need to fiddle with zmacs_region_stays, now that bogus clearing of it (see below) is removed. * search.c (Freplace_match): warning fix.
author ben
date Fri, 04 May 2001 22:42:35 +0000
parents 54fa1a5c2d12
children 98fb34b6fbe9
line wrap: on
line diff
--- a/lisp/simple.el	Thu May 03 21:08:39 2001 +0000
+++ b/lisp/simple.el	Fri May 04 22:42:35 2001 +0000
@@ -58,10 +58,10 @@
 ;; this isn't a user-visible change.  These functions have also been altered
 ;; to use (mark t) for the same reason.
 
-;; 97/3/14 Jareth Hein (jhod@po.iijnet.or.jp) added kinsoku processing (support
-;; for filling of Asian text) into the fill code. This was ripped bleeding from
-;; Mule-2.3, and could probably use some feature additions (like additional wrap
-;; styles, etc)
+;; 97/3/14 Jareth Hein (jhod@po.iijnet.or.jp) added kinsoku processing
+;; (support for filling of Asian text) into the fill code. This was
+;; ripped bleeding from Mule-2.3, and could probably use some feature
+;; additions (like additional wrap styles, etc)
 
 ;; 97/06/11 Steve Baur (steve@xemacs.org) Convert use of
 ;;  (preceding|following)-char to char-(after|before).
@@ -453,7 +453,8 @@
 (defsubst delete-forward-p ()
   (and delete-key-deletes-forward
        (or (not (eq (device-type) 'x))
-	   (x-keysym-on-keyboard-sans-modifiers-p 'backspace))))
+	   (declare-fboundp
+	     (x-keysym-on-keyboard-sans-modifiers-p 'backspace)))))
 
 (defun backward-or-forward-delete-char (arg)
   "Delete either one character backwards or one character forwards.
@@ -2791,6 +2792,15 @@
       (if arg (forward-line 1))
       (setq count (1- count)))))
 
+;; This variable: Synched up with 20.7.
+(defvar comment-padding 1
+  "Number of spaces `comment-region' puts between comment chars and text.
+
+Extra spacing between the comment characters and the comment text
+makes the comment easier to read.  Default is 1.  Nil means 0 and is
+more efficient.")
+
+;; This function: Synched up with 20.7.
 (defun comment-region (start end &optional arg)
   "Comment or uncomment each line in the region.
 With just C-u prefix arg, uncomment each line in region.
@@ -2808,6 +2818,8 @@
   (save-excursion
     (save-restriction
       (let ((cs comment-start) (ce comment-end)
+	    (cp (when comment-padding
+		  (make-string comment-padding ? )))
 	    numarg)
         (if (consp arg) (setq numarg t)
 	  (setq numarg (prefix-numeric-value arg))
@@ -2820,17 +2832,40 @@
 	;; Loop over all lines from START to END.
         (narrow-to-region start end)
         (goto-char start)
-        (while (not (eobp))
-          (if (or (eq numarg t) (< numarg 0))
-	      (progn
+	;; if user didn't specify how many comments to remove, be smart
+	;; and remove the minimal number that all lines have.  that way,
+	;; comments in a region of Elisp code that gets commented out will
+	;; get put back correctly.
+	(if (eq numarg t)
+	    (let ((min-comments 999999))
+	      (while (not (eobp))
+		(let ((this-comments 0))
+		  (while (looking-at (regexp-quote cs))
+		    (incf this-comments)
+		    (forward-char (length cs)))
+		  (if (and (> this-comments 0) (< this-comments min-comments))
+		      (setq min-comments this-comments))
+		  (forward-line 1)))
+	      (if (< min-comments 999999)
+		  (setq numarg (- min-comments)))
+	      (goto-char start)))
+	(if (or (eq numarg t) (< numarg 0))
+	    (while (not (eobp))
+	      (let (found-comment)
 		;; Delete comment start from beginning of line.
 		(if (eq numarg t)
 		    (while (looking-at (regexp-quote cs))
+		      (setq found-comment t)
 		      (delete-char (length cs)))
 		  (let ((count numarg))
 		    (while (and (> 1 (setq count (1+ count)))
 				(looking-at (regexp-quote cs)))
+		      (setq found-comment t)
 		      (delete-char (length cs)))))
+		;; Delete comment padding from beginning of line
+		(when (and found-comment comment-padding
+			   (looking-at (regexp-quote cp)))
+		  (delete-char comment-padding))
 		;; Delete comment end from end of line.
                 (if (string= "" ce)
 		    nil
@@ -2840,23 +2875,29 @@
 			;; This is questionable if comment-end ends in
 			;; whitespace.  That is pretty brain-damaged,
 			;; though.
-			(skip-chars-backward " \t")
-			(if (and (>= (- (point) (point-min)) (length ce))
-				 (save-excursion
-				   (backward-char (length ce))
-				   (looking-at (regexp-quote ce))))
-			    (delete-char (- (length ce)))))
+			(while (progn (skip-chars-backward " \t")
+				      (and (>= (- (point) (point-min))
+					       (length ce))
+					   (save-excursion
+					     (backward-char (length ce))
+					     (looking-at (regexp-quote ce)))))
+			  (delete-char (- (length ce)))))
 		    (let ((count numarg))
 		      (while (> 1 (setq count (1+ count)))
 			(end-of-line)
 			;; This is questionable if comment-end ends in
 			;; whitespace.  That is pretty brain-damaged though
 			(skip-chars-backward " \t")
-			(save-excursion
-			  (backward-char (length ce))
-			  (if (looking-at (regexp-quote ce))
-			      (delete-char (length ce))))))))
-		(forward-line 1))
+			(if (>= (- (point) (point-min)) (length ce))
+			    (save-excursion
+			      (backward-char (length ce))
+			      (if (looking-at (regexp-quote ce))
+				  (delete-char (length ce)))))))))
+		(forward-line 1)))
+
+	  (when comment-padding
+	    (setq cs (concat cs cp)))
+	  (while (not (eobp))
 	    ;; Insert at beginning and at end.
             (if (looking-at "[ \t]*$") ()
               (insert cs)
@@ -2989,12 +3030,11 @@
 		(fill-point
 		 (let ((opoint (point))
 		       bounce
-		       ;; 97/3/14 jhod: Kinsoku
-		       (re-break-point (if (featurep 'mule)
-					    (concat "[ \t\n]\\|" word-across-newline
-						    ".\\|." word-across-newline)
-					"[ \t\n]"))
-		       ;; end patch
+		       (re-break-point ;; Kinsoku processing
+			(if (featurep 'mule)
+			    (concat "[ \t\n]\\|" word-across-newline
+				    ".\\|." word-across-newline)
+			  "[ \t\n]"))
 		       (first t))
 		   (save-excursion
 		     (move-to-column (1+ fill-column))
@@ -3011,24 +3051,21 @@
 						     (and (looking-at "\\. ")
 							  (not (looking-at "\\.  "))))))
 		       (setq first nil)
-		       ;; 97/3/14 jhod: Kinsoku
-		       ; (skip-chars-backward "^ \t\n"))
+		       ;; XEmacs: change for Kinsoku processing
 		       (fill-move-backward-to-break-point re-break-point)
-		       ;; end patch
 		       ;; If we find nowhere on the line to break it,
 		       ;; break after one word.  Set bounce to t
 		       ;; so we will not keep going in this while loop.
 		       (if (bolp)
 			   (progn
-			     ;; 97/3/14 jhod: Kinsoku
-			     ; (re-search-forward "[ \t]" opoint t)
+			     ;; XEmacs: change for Kinsoku processing
 			     (fill-move-forward-to-break-point re-break-point
 							       opoint)
-			     ;; end patch
 			     (setq bounce t)))
 		       (skip-chars-backward " \t"))
 		     (if (and (featurep 'mule)
-			      (or bounce (bolp))) (kinsoku-process)) ;; 97/3/14 jhod: Kinsoku
+			      (or bounce (bolp)))
+			 (declare-fboundp (kinsoku-process)))
 		     ;; Let fill-point be set to the place where we end up.
 		     (point)))))
 
@@ -3047,7 +3084,8 @@
 	    ;; break the line there.
 	    (if (save-excursion
 		  (goto-char fill-point)
-		  (not (or (bolp) (eolp)))) ; 97/3/14 jhod: during kinsoku processing it is possible to move beyond
+		  ;; during kinsoku processing it is possible to move beyond
+		  (not (or (bolp) (eolp))))
 		(let ((prev-column (current-column)))
 		  ;; If point is at the fill-point, do not `save-excursion'.
 		  ;; Otherwise, if a comment prefix or fill-prefix is inserted,
@@ -3058,7 +3096,7 @@
 		      ;; 1999-09-17 hniksic: turn off Kinsoku until
 		      ;; it's debugged.
 		      (funcall comment-line-break-function)
-		      ;; 97/3/14 jhod: Kinsoku processing
+		      ;; XEmacs: Kinsoku processing
 ;		      ;(indent-new-comment-line)
 ;		      (let ((spacep (memq (char-before (point)) '(?\  ?\t))))
 ;			(funcall comment-line-break-function)
@@ -3248,9 +3286,8 @@
   (interactive)
   (let (comcol comstart)
     (skip-chars-backward " \t")
-    ;; 97/3/14 jhod: Kinsoku processing
     (if (featurep 'mule)
-	(kinsoku-process))
+	(declare-fboundp (kinsoku-process)))
     (delete-region (point)
 		   (progn (skip-chars-forward " \t")
 			  (point)))
@@ -3868,14 +3905,28 @@
  the region is active.  Otherwise, this means that the user has pushed
  a mark in this buffer at some point in the past.
 The functions `region-beginning' and `region-end' can be used to find the
- limits of the region."
+ limits of the region.
+
+You should use this, *NOT* `region-active-p', in a menu item
+specification that you want grayed out when the region is not active:
+
+  [ ... ... :active (region-exists-p)]
+
+This correctly caters to the user's setting of `zmacs-regions'."
   (not (null (mark))))
 
 ;; XEmacs
 (defun region-active-p ()
   "Return non-nil if the region is active.
 If `zmacs-regions' is true, this is equivalent to `region-exists-p'.
-Otherwise, this function always returns false."
+Otherwise, this function always returns false.
+
+You should generally *NOT* use this in a menu item specification that you
+want grayed out when the region is not active.  Instead, use this:
+
+  [ ... ... :active (region-exists-p)]
+
+Which correctly caters to the user's setting of `zmacs-regions'."
   (and zmacs-regions zmacs-region-extent))
 
 (defvar zmacs-activate-region-hook nil
@@ -4216,8 +4267,7 @@
   (or frame (setq frame (selected-frame)))
   (let ((clear-stream (and message-stack (eq 'stream (frame-type frame)))))
     (remove-message label frame)
-    (let ((inhibit-read-only t)
-	  (zmacs-region-stays zmacs-region-stays)) ; preserve from change
+    (let ((inhibit-read-only t))
       (erase-buffer " *Echo Area*"))
     (if clear-stream
 	(send-string-to-terminal ?\n stdout-p))
@@ -4275,8 +4325,7 @@
 ;; message-stack.
 (defun raw-append-message (message &optional frame stdout-p)
   (unless (equal message "")
-    (let ((inhibit-read-only t)
-	  (zmacs-region-stays zmacs-region-stays)) ; preserve from change
+    (let ((inhibit-read-only t))
       (insert-string message " *Echo Area*")
       ;; Conditionalizing on the device type in this way is not that clean,
       ;; but neither is having a device method, as I originally implemented