diff lisp/simple.el @ 17713:be8005fce86f

(quoted-insert-character-offset): Initialize more cleanly. (quoted-insert): Don't offset codes above 377.
author Richard M. Stallman <rms@gnu.org>
date Sat, 10 May 1997 00:39:44 +0000
parents d2c64a1563f7
children 40a43a90976f
line wrap: on
line diff
--- a/lisp/simple.el	Sat May 10 00:37:24 1997 +0000
+++ b/lisp/simple.el	Sat May 10 00:39:44 1997 +0000
@@ -156,8 +156,10 @@
     (indent-to col 0)
     (goto-char pos)))
 
-(defvar quoted-insert-character-offset 2048
-  "Offset added by \\[quoted-insert] to character codes 0200 and above.")
+(defcustom quoted-insert-character-offset (- (make-char 'latin-iso8859-1) 128)
+  "*Offset added by \\[quoted-insert] to character codes 0200 and above."
+  :tag 'integer
+  :group 'i18n)
 
 (defun quoted-insert (arg)
   "Read next input character and insert it.
@@ -182,6 +184,7 @@
     ;; to Emacs characters.
     (and enable-multibyte-characters
 	 (>= char ?\200)
+	 (<= char ?\377)
 	 (setq char (+ quoted-insert-character-offset char)))
     (if (> arg 0)
 	(if (eq overwrite-mode 'overwrite-mode-binary)
@@ -1152,13 +1155,74 @@
 	       ;; the value of point from before the command was run.
 	       (progn
 		 (if arg
-		     (forward-line (prefix-numeric-value arg))
+		     (forward-visible-line (prefix-numeric-value arg))
 		   (if (eobp)
 		       (signal 'end-of-buffer nil))
 		   (if (or (looking-at "[ \t]*$") (and kill-whole-line (bolp)))
-		       (forward-line 1)
-		     (end-of-line)))
+		       (forward-visible-line 1)
+		     (end-of-visible-line)))
 		 (point))))
+
+(defun forward-visible-line (arg)
+  "Move forward by ARG lines, ignoring currently invisible newlines only."
+  (condition-case nil
+      (progn
+	(while (> arg 0)
+	  (or (zerop (forward-line 1))
+	      (signal 'end-of-buffer nil))
+	  ;; If the following character is currently invisible,
+	  ;; skip all characters with that same `invisible' property value,
+	  ;; then find the next newline.
+	  (while (and (not (eobp))
+		      (let ((prop
+			     (get-char-property (point) 'invisible)))
+			(if (eq buffer-invisibility-spec t)
+			    prop
+			  (or (memq prop buffer-invisibility-spec)
+			      (assq prop buffer-invisibility-spec)))))
+	    (if (get-text-property (point) 'invisible)
+		(goto-char (next-single-property-change (point) 'invisible))
+	      (goto-char (next-overlay-change (point))))
+	    (or (zerop (forward-line 1))
+		(signal 'end-of-buffer nil)))
+	  (setq arg (1- arg)))
+	(while (< arg 0)
+	  (or (zerop (vertical-motion -1))
+	      (signal 'beginning-of-buffer nil))
+	  (while (and (not (bobp))
+		      (let ((prop
+			     (get-char-property (1- (point)) 'invisible)))
+			(if (eq buffer-invisibility-spec t)
+			    prop
+			  (or (memq prop buffer-invisibility-spec)
+			      (assq prop buffer-invisibility-spec)))))
+	    (if (get-text-property (1- (point)) 'invisible)
+		(goto-char (previous-single-property-change (point) 'invisible))
+	      (goto-char (previous-overlay-change (point))))
+	    (or (zerop (vertical-motion -1))
+		(signal 'beginning-of-buffer nil)))
+	  (setq arg (1+ arg))))
+    ((beginning-of-buffer end-of-buffer)
+     nil)))
+
+(defun end-of-visible-line ()
+  "Move to end of current visible line."
+  (end-of-line)
+  ;; If the following character is currently invisible,
+  ;; skip all characters with that same `invisible' property value,
+  ;; then find the next newline.
+  (while (and (not (eobp))
+	      (let ((prop
+		     (get-char-property (point) 'invisible)))
+		(if (eq buffer-invisibility-spec t)
+		    prop
+		  (or (memq prop buffer-invisibility-spec)
+		      (assq prop buffer-invisibility-spec)))))
+    (if (get-text-property (point) 'invisible)
+	(goto-char (next-single-property-change (point) 'invisible))
+      (goto-char (next-overlay-change (point))))
+    (forward-char 1)
+    (end-of-line)))
 
 ;;;; Window system cut and paste hooks.
 
@@ -3026,6 +3090,7 @@
 
 (defun assoc-ignore-case (key alist)
   "Like `assoc', but assumes KEY is a string and ignores case when comparing."
+  (setq key (downcase key))
   (let (element)
     (while (and alist (not element))
       (if (equal key (downcase (car (car alist))))