changeset 91813:ca1e1298a3d8

(smerge-auto-combine-max-separation): New var. (smerge-auto-combine): New fun.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 13 Feb 2008 15:10:57 +0000
parents 22cb32652c70
children c1e1558393ba
files lisp/ChangeLog lisp/smerge-mode.el src/ccl.h src/coding.h src/font.h src/lisp.h
diffstat 6 files changed, 68 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Feb 12 23:41:59 2008 +0000
+++ b/lisp/ChangeLog	Wed Feb 13 15:10:57 2008 +0000
@@ -1,3 +1,8 @@
+2008-02-13  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* smerge-mode.el (smerge-auto-combine-max-separation): New var.
+	(smerge-auto-combine): New fun.
+
 2008-02-12  Juri Linkov  <juri@jurta.org>
 
 	* startup.el (fancy-startup-screen, normal-splash-screen):
@@ -6,8 +11,8 @@
 	* desktop.el (after-init-hook): Set inhibit-startup-screen to t
 	after reading the desktop.
 
-	* progmodes/compile.el (compilation-auto-jump): Call
-	compile-goto-error only when compilation-auto-jump-to-first-error
+	* progmodes/compile.el (compilation-auto-jump):
+	Call compile-goto-error only when compilation-auto-jump-to-first-error
 	is non-nil.
 	(compilation-scroll-output): Replace :type 'boolean with a choice
 	that has three options including a third option `first-error'.
--- a/lisp/smerge-mode.el	Tue Feb 12 23:41:59 2008 +0000
+++ b/lisp/smerge-mode.el	Wed Feb 13 15:10:57 2008 +0000
@@ -297,6 +297,8 @@
 
 (defun smerge-combine-with-next ()
   "Combine the current conflict with the next one."
+  ;; `smerge-auto-combine' relies on the finish position (at the beginning
+  ;; of the closing marker).
   (interactive)
   (smerge-match-conflict)
   (let ((ends nil))
@@ -328,6 +330,25 @@
 	(dolist (m match-data) (if m (move-marker m nil)))
 	(mapc (lambda (m) (if m (move-marker m nil))) ends)))))
 
+(defvar smerge-auto-combine-max-separation 2
+  "Max number of lines between conflicts that should be combined.")
+
+(defun smerge-auto-combine ()
+  "Automatically combine conflicts that are near each other."
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (while (smerge-find-conflict)
+      ;; 2 is 1 (default) + 1 (the begin markers).
+      (while (save-excursion
+               (smerge-find-conflict
+                (line-beginning-position
+                 (+ 2 smerge-auto-combine-max-separation))))
+        (forward-line -1)               ;Go back inside the conflict.
+        (smerge-combine-with-next)
+        (forward-line 1)                ;Move past the end of the conflict.
+        ))))
+
 (defvar smerge-resolve-function
   (lambda () (error "Don't know how to resolve"))
   "Mode-specific merge function.
--- a/src/ccl.h	Tue Feb 12 23:41:59 2008 +0000
+++ b/src/ccl.h	Wed Feb 13 15:10:57 2008 +0000
@@ -117,7 +117,7 @@
 #define CHECK_CCL_PROGRAM(x)			\
   do {						\
     if (NILP (Fccl_program_p (x)))		\
-      x = wrong_type_argument (Qcclp, (x));	\
+      wrong_type_argument (Qcclp, (x));	\
   } while (0);
 
 #endif /* EMACS_CCL_H */
--- a/src/coding.h	Tue Feb 12 23:41:59 2008 +0000
+++ b/src/coding.h	Wed Feb 13 15:10:57 2008 +0000
@@ -161,23 +161,23 @@
 
 /* Macros to access an element of an attribute vector.  */
 
-#define CODING_ATTR_BASE_NAME(attrs)	AREF (attrs, coding_attr_base_name)
-#define CODING_ATTR_TYPE(attrs)		AREF (attrs, coding_attr_type)
-#define CODING_ATTR_CHARSET_LIST(attrs)	AREF (attrs, coding_attr_charset_list)
-#define CODING_ATTR_MNEMONIC(attrs)	AREF (attrs, coding_attr_mnemonic)
-#define CODING_ATTR_DOCSTRING(attrs)	AREF (attrs, coding_attr_docstring)
-#define CODING_ATTR_ASCII_COMPAT(attrs)	AREF (attrs, coding_attr_ascii_compat)
-#define CODING_ATTR_DECODE_TBL(attrs)	AREF (attrs, coding_attr_decode_tbl)
-#define CODING_ATTR_ENCODE_TBL(attrs)	AREF (attrs, coding_attr_encode_tbl)
-#define CODING_ATTR_TRANS_TBL(attrs)	AREF (attrs, coding_attr_trans_tbl)
-#define CODING_ATTR_POST_READ(attrs)	AREF (attrs, coding_attr_post_read)
-#define CODING_ATTR_PRE_WRITE(attrs)	AREF (attrs, coding_attr_pre_write)
-#define CODING_ATTR_DEFAULT_CHAR(attrs)	AREF (attrs, coding_attr_default_char)
-#define CODING_ATTR_FOR_UNIBYTE(attrs)	AREF (attrs, coding_attr_for_unibyte)
-#define CODING_ATTR_FLUSHING(attrs)	AREF (attrs, coding_attr_flushing)
-#define CODING_ATTR_PLIST(attrs)	AREF (attrs, coding_attr_plist)
-#define CODING_ATTR_CATEGORY(attrs)	AREF (attrs, coding_attr_category)
-#define CODING_ATTR_SAFE_CHARSETS(attrs)AREF (attrs, coding_attr_safe_charsets)
+#define CODING_ATTR_BASE_NAME(attrs)	ASLOT (attrs, coding_attr_base_name)
+#define CODING_ATTR_TYPE(attrs)		ASLOT (attrs, coding_attr_type)
+#define CODING_ATTR_CHARSET_LIST(attrs)	ASLOT (attrs, coding_attr_charset_list)
+#define CODING_ATTR_MNEMONIC(attrs)	ASLOT (attrs, coding_attr_mnemonic)
+#define CODING_ATTR_DOCSTRING(attrs)	ASLOT (attrs, coding_attr_docstring)
+#define CODING_ATTR_ASCII_COMPAT(attrs)	ASLOT (attrs, coding_attr_ascii_compat)
+#define CODING_ATTR_DECODE_TBL(attrs)	ASLOT (attrs, coding_attr_decode_tbl)
+#define CODING_ATTR_ENCODE_TBL(attrs)	ASLOT (attrs, coding_attr_encode_tbl)
+#define CODING_ATTR_TRANS_TBL(attrs)	ASLOT (attrs, coding_attr_trans_tbl)
+#define CODING_ATTR_POST_READ(attrs)	ASLOT (attrs, coding_attr_post_read)
+#define CODING_ATTR_PRE_WRITE(attrs)	ASLOT (attrs, coding_attr_pre_write)
+#define CODING_ATTR_DEFAULT_CHAR(attrs)	ASLOT (attrs, coding_attr_default_char)
+#define CODING_ATTR_FOR_UNIBYTE(attrs)	ASLOT (attrs, coding_attr_for_unibyte)
+#define CODING_ATTR_FLUSHING(attrs)	ASLOT (attrs, coding_attr_flushing)
+#define CODING_ATTR_PLIST(attrs)	ASLOT (attrs, coding_attr_plist)
+#define CODING_ATTR_CATEGORY(attrs)	ASLOT (attrs, coding_attr_category)
+#define CODING_ATTR_SAFE_CHARSETS(attrs)ASLOT (attrs, coding_attr_safe_charsets)
 
 
 /* Return the name of a coding system specified by ID.  */
@@ -241,7 +241,7 @@
 	spec = CODING_SYSTEM_SPEC (x);			\
       }							\
     if (NILP (spec))					\
-      x = wrong_type_argument (Qcoding_system_p, (x));	\
+      wrong_type_argument (Qcoding_system_p, (x));	\
   } while (0)
 
 
@@ -258,7 +258,7 @@
 	  id = CODING_SYSTEM_ID (x);				\
 	}							\
       if (id < 0)						\
-	x = wrong_type_argument (Qcoding_system_p, (x));	\
+	wrong_type_argument (Qcoding_system_p, (x));	\
     } while (0)
 
 
--- a/src/font.h	Tue Feb 12 23:41:59 2008 +0000
+++ b/src/font.h	Wed Feb 13 15:10:57 2008 +0000
@@ -233,17 +233,17 @@
 /* Check macros for various font-related objects.  */
 
 #define CHECK_FONT(x)	\
-  do { if (! FONTP (x)) x = wrong_type_argument (Qfont, x); } while (0)
+  do { if (! FONTP (x)) wrong_type_argument (Qfont, x); } while (0)
 #define CHECK_FONT_SPEC(x)	\
-  do { if (! FONT_SPEC_P (x)) x = wrong_type_argument (Qfont, x); } while (0)
+  do { if (! FONT_SPEC_P (x)) wrong_type_argument (Qfont, x); } while (0)
 #define CHECK_FONT_ENTITY(x)	\
-  do { if (! FONT_ENTITY_P (x)) x = wrong_type_argument (Qfont, x); } while (0)
+  do { if (! FONT_ENTITY_P (x)) wrong_type_argument (Qfont, x); } while (0)
 #define CHECK_FONT_OBJECT(x)	\
-  do { if (! FONT_OBJECT_P (x)) x = wrong_type_argument (Qfont, x); } while (0)
+  do { if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont, x); } while (0)
 
 #define CHECK_FONT_GET_OBJECT(x, font)					\
   do {									\
-    if (! FONT_OBJECT_P (x)) x = wrong_type_argument (Qfont, x);	\
+    if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont, x);	\
     if (! XSAVE_VALUE (x)->pointer) error ("Font already closed");	\
     font = XSAVE_VALUE (x)->pointer;					\
   } while (0)
--- a/src/lisp.h	Tue Feb 12 23:41:59 2008 +0000
+++ b/src/lisp.h	Wed Feb 13 15:10:57 2008 +0000
@@ -588,13 +588,17 @@
 
 /* Convenience macros for dealing with Lisp arrays.  */
 
-#define AREF(ARRAY, IDX)	XVECTOR ((ARRAY))->contents[IDX]
+#define ASLOT(ARRAY, IDX)	XVECTOR ((ARRAY))->contents[IDX]
 #define ASIZE(ARRAY)		XVECTOR ((ARRAY))->size
-/* The IDX==IDX tries to detect when the macro argument is side-effecting.  */
+/* The IDX==IDX checks that the macro argument is not side-effecting.  */
+#define AREF(ARRAY, IDX)	\
+  (eassert ((IDX) == (IDX)),				\
+   eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)),	\
+   ASLOT (ARRAY, (IDX)))
 #define ASET(ARRAY, IDX, VAL)	\
   (eassert ((IDX) == (IDX)),				\
    eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)),	\
-   AREF ((ARRAY), (IDX)) = (VAL))
+   ASLOT ((ARRAY), (IDX)) = (VAL))
 
 /* Convenience macros for dealing with Lisp strings.  */
 
@@ -686,12 +690,12 @@
 #define CAR(c)					\
  (CONSP ((c)) ? XCAR ((c))			\
   : NILP ((c)) ? Qnil				\
-  : wrong_type_argument (Qlistp, (c)))
+  : (wrong_type_argument (Qlistp, (c)), Qnil))
 
 #define CDR(c)					\
  (CONSP ((c)) ? XCDR ((c))			\
   : NILP ((c)) ? Qnil				\
-  : wrong_type_argument (Qlistp, (c)))
+  : (wrong_type_argument (Qlistp, (c)), Qnil))
 
 /* Take the car or cdr of something whose type is not known.  */
 #define CAR_SAFE(c)				\
@@ -1090,25 +1094,25 @@
 
 /* Value is the key part of entry IDX in hash table H.  */
 
-#define HASH_KEY(H, IDX)   AREF ((H)->key_and_value, 2 * (IDX))
+#define HASH_KEY(H, IDX)   ASLOT ((H)->key_and_value, 2 * (IDX))
 
 /* Value is the value part of entry IDX in hash table H.  */
 
-#define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1)
+#define HASH_VALUE(H, IDX) ASLOT ((H)->key_and_value, 2 * (IDX) + 1)
 
 /* Value is the index of the next entry following the one at IDX
    in hash table H.  */
 
-#define HASH_NEXT(H, IDX)  AREF ((H)->next, (IDX))
+#define HASH_NEXT(H, IDX)  ASLOT ((H)->next, (IDX))
 
 /* Value is the hash code computed for entry IDX in hash table H.  */
 
-#define HASH_HASH(H, IDX)  AREF ((H)->hash, (IDX))
+#define HASH_HASH(H, IDX)  ASLOT ((H)->hash, (IDX))
 
 /* Value is the index of the element in hash table H that is the
    start of the collision list at index IDX in the index vector of H.  */
 
-#define HASH_INDEX(H, IDX)  AREF ((H)->index, (IDX))
+#define HASH_INDEX(H, IDX)  ASLOT ((H)->index, (IDX))
 
 /* Value is the size of hash table H.  */
 
@@ -2252,7 +2256,7 @@
 extern void args_out_of_range P_ ((Lisp_Object, Lisp_Object)) NO_RETURN;
 extern void args_out_of_range_3 P_ ((Lisp_Object, Lisp_Object,
 				     Lisp_Object)) NO_RETURN;
-extern Lisp_Object wrong_type_argument P_ ((Lisp_Object, Lisp_Object)) NO_RETURN;
+extern void wrong_type_argument P_ ((Lisp_Object, Lisp_Object)) NO_RETURN;
 extern void store_symval_forwarding P_ ((Lisp_Object, Lisp_Object,
 					 Lisp_Object, struct buffer *));
 extern Lisp_Object do_symval_forwarding P_ ((Lisp_Object));