/* For consistency with format-decode call these now iff inserted > 0
(martin 2007-06-28). */
p = Vafter_insert_file_functions;
- while (CONSP (p))
+ FOR_EACH_TAIL (p)
{
if (NILP (replace))
{
inserted = XFIXNAT (insval);
}
}
-
- maybe_quit ();
- p = XCDR (p);
}
if (!empty_undo_list_p)
Lisp_Object annotations;
Lisp_Object p, res;
Lisp_Object original_buffer;
- int i;
bool used_global = false;
XSETBUFFER (original_buffer, current_buffer);
annotations = Qnil;
p = Vwrite_region_annotate_functions;
- while (CONSP (p))
+ loop_over_p:
+ FOR_EACH_TAIL (p)
{
struct buffer *given_buffer = current_buffer;
if (EQ (Qt, XCAR (p)) && !used_global)
p = CALLN (Fappend,
Fdefault_value (Qwrite_region_annotate_functions),
XCDR (p));
- continue;
+ goto loop_over_p;
}
Vwrite_region_annotations_so_far = annotations;
res = call2 (XCAR (p), start, end);
}
Flength (res); /* Check basic validity of return value */
annotations = merge (annotations, res, Qcar_less_than_car);
- p = XCDR (p);
}
/* Now do the same for annotation functions implied by the file-format */
p = BVAR (current_buffer, auto_save_file_format);
else
p = BVAR (current_buffer, file_format);
- for (i = 0; CONSP (p); p = XCDR (p), ++i)
+ EMACS_INT i = 0;
+ FOR_EACH_TAIL (p)
{
struct buffer *given_buffer = current_buffer;
has written annotations to a temporary buffer, which is now
current. */
res = call5 (Qformat_annotate_function, XCAR (p), start, end,
- original_buffer, make_fixnum (i));
+ original_buffer, make_fixnum (i++));
if (current_buffer != given_buffer)
{
XSETFASTINT (start, BEGV);
(should (file-name-absolute-p (concat "~" user-login-name suffix))))
(unless (user-full-name "nosuchuser")
(should (not (file-name-absolute-p (concat "~nosuchuser" suffix)))))))
+
+(ert-deftest fileio-tests--circular-after-insert-file-functions ()
+ "Test after-insert-file-functions as a circular list."
+ (let ((f (make-temp-file "fileio"))
+ (after-insert-file-functions (list 'identity)))
+ (setcdr after-insert-file-functions after-insert-file-functions)
+ (write-region "hello\n" nil f nil 'silent)
+ (should-error (insert-file-contents f) :type 'circular-list)
+ (delete-file f)))