From 02dfeba8a4ce93dadd7f5fa7f462fca12fdf28f8 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 13 Feb 2008 15:10:57 +0000 Subject: [PATCH] (smerge-auto-combine-max-separation): New var. (smerge-auto-combine): New fun. --- lisp/ChangeLog | 9 +++++++-- lisp/smerge-mode.el | 21 +++++++++++++++++++++ src/ccl.h | 2 +- src/coding.h | 38 +++++++++++++++++++------------------- src/font.h | 10 +++++----- src/lisp.h | 26 +++++++++++++++----------- 6 files changed, 68 insertions(+), 38 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 927b3ce86aa..cfd106aca27 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-02-13 Stefan Monnier + + * smerge-mode.el (smerge-auto-combine-max-separation): New var. + (smerge-auto-combine): New fun. + 2008-02-12 Juri Linkov * 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'. diff --git a/lisp/smerge-mode.el b/lisp/smerge-mode.el index f2a7a9caf9e..8a3f15bac44 100644 --- a/lisp/smerge-mode.el +++ b/lisp/smerge-mode.el @@ -297,6 +297,8 @@ Can be nil if the style is undecided, or else: (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 @@ Can be nil if the style is undecided, or else: (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. diff --git a/src/ccl.h b/src/ccl.h index 3afb135fb56..4ac8b990fee 100644 --- a/src/ccl.h +++ b/src/ccl.h @@ -117,7 +117,7 @@ EXFUN (Fccl_program_p, 1); #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 */ diff --git a/src/coding.h b/src/coding.h index 34196082afb..eba77273308 100644 --- a/src/coding.h +++ b/src/coding.h @@ -161,23 +161,23 @@ enum coding_attr_index /* 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 @@ enum coding_attr_index 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 @@ enum coding_attr_index 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) diff --git a/src/font.h b/src/font.h index b8aa4e1f3a4..21e821e6e71 100644 --- a/src/font.h +++ b/src/font.h @@ -233,17 +233,17 @@ struct font_bitmap /* 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) diff --git a/src/lisp.h b/src/lisp.h index 8221a85c13e..f72c15e9d76 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -588,13 +588,17 @@ extern size_t pure_size; /* 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 @@ struct Lisp_Cons #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 @@ struct Lisp_Hash_Table /* 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 unsigned long cons_to_long P_ ((Lisp_Object)); 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)); -- 2.39.5