(smerge-auto-combine): New fun.
+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):
* 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'.
(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))
(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.
#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 */
/* 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. */
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)
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)
/* 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)
/* 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. */
#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) \
/* 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. */
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));