diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 166 | ||||
-rw-r--r-- | src/alloc.c | 109 | ||||
-rw-r--r-- | src/atimer.c | 2 | ||||
-rw-r--r-- | src/data.c | 1 | ||||
-rw-r--r-- | src/dispnew.c | 4 | ||||
-rw-r--r-- | src/emacs.c | 25 | ||||
-rw-r--r-- | src/eval.c | 7 | ||||
-rw-r--r-- | src/fileio.c | 16 | ||||
-rw-r--r-- | src/floatfns.c | 1 | ||||
-rw-r--r-- | src/indent.c | 5 | ||||
-rw-r--r-- | src/keyboard.c | 66 | ||||
-rw-r--r-- | src/lisp.h | 11 | ||||
-rw-r--r-- | src/macterm.c | 102 | ||||
-rw-r--r-- | src/minibuf.c | 30 | ||||
-rw-r--r-- | src/process.c | 3 | ||||
-rw-r--r-- | src/regex.c | 4 | ||||
-rw-r--r-- | src/syntax.c | 6 | ||||
-rw-r--r-- | src/sysdep.c | 1 | ||||
-rw-r--r-- | src/syssignal.h | 27 | ||||
-rw-r--r-- | src/term.c | 2 | ||||
-rw-r--r-- | src/undo.c | 156 | ||||
-rw-r--r-- | src/w32term.c | 30 | ||||
-rw-r--r-- | src/xdisp.c | 22 | ||||
-rw-r--r-- | src/xselect.c | 2 | ||||
-rw-r--r-- | src/xterm.c | 31 |
25 files changed, 577 insertions, 252 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 38a079989be..8d09c5bfd2f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,159 @@ +2004-12-22 Richard M. Stallman <rms@gnu.org> + + * emacs.c (main): If batch mode, set Vundo_outer_limit to nil. + + * lisp.h (Vundo_outer_limit): Fix decl. + + * undo.c (Vundo_outer_limit): Replaces undo_outer_limit. + Uses changed. + (syms_of_undo): Initialize appropriately. + (truncate_undo_list): If it's nil, there's no limit. + +2004-12-22 Kenichi Handa <handa@m17n.org> + + * xselect.c (Fx_get_cut_buffer_internal): Return a unibyte string. + +2004-12-21 Richard M. Stallman <rms@gnu.org> + + * eval.c (unwind_to_catch): Clear immediate_quit. + + * xdisp.c (get_next_display_element): Display codes 8a0 and 8ad + specially as `\ ' and `\-'. + + * keyboard.c (kbd_buffer_store_event_hold): + In the code for while-no-input, handle immediate_quit. + + * alloc.c (Fgarbage_collect): Update call to truncate_undo_list. + Call that at the very start. + (undo_limit, undo_strong_limit, undo_outer_limit): Moved to undo.c. + (syms_of_alloc): Don't define undo-limit, + undo-strong-limit and undo-outer-limit here. + + * undo.c (truncate_undo_list): Return void. + Take just one argument, the buffer. + Make it current, and inhibit recursive GC. + Access and update the undo list directly; return void. + Refer to the undo...limit variables directly. + Test undo_outer_limit only after counting the whole current command. + When it's exceeded, call the function in undo-outer-limit-function. + (undo_limit, undo_strong_limit, undo_outer_limit): From alloc.c. + (Vundo_outer_limit_function): New variable. + (syms_of_undo): Define undo-limit, undo-strong-limit + and undo-outer-limit here, and undo-outer-limit-function. + Doc fixes. + + * lisp.h (truncate_undo_list): Update decl. + +2004-12-21 Piet van Oostrum <piet@cs.uu.nl> + + * fileio.c (Fread_file_name): Delete duplicates in + file-name-history when history_delete_duplicates is true. + +2004-12-20 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * macterm.c (mac_do_list_fonts): Fix memory leak + +2004-12-20 Richard M. Stallman <rms@gnu.org> + + * regex.c (re_match_2_internal) <symend, wordend>: + Fix calls to UPDATE_SYNTAX_TABLE_FORWARD. + +2004-12-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * macterm.c (endif, x_font_name_to_mac_font_name): Use + maccentraleurroman instead of maccentraleuropean + (mac_c_string_match, mac_do_list_fonts): Speed up font search by + quickly finding a specific font without needing regexps. + +2004-12-15 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * syssignal.h: Declare main_thread. + (SIGNAL_THREAD_CHECK): New macro. + + * keyboard.c (input_available_signal): Move thread checking code + to macro SIGNAL_THREAD_CHECK and call that macro. + (interrupt_signal): Call SIGNAL_THREAD_CHECK. + + * alloc.c (uninterrupt_malloc): Move main_thread to emacs.c. + + * emacs.c: Define main_thread. + (main): Initialize main_thread. + (handle_USR1_signal, handle_USR2_signal, fatal_error_signal) + (memory_warning_signal): Call SIGNAL_THREAD_CHECK. + + * floatfns.c (float_error): Call SIGNAL_THREAD_CHECK. + + * dispnew.c (window_change_signal): Call SIGNAL_THREAD_CHECK. + + * sysdep.c (select_alarm): Call SIGNAL_THREAD_CHECK. + + * process.c (send_process_trap, sigchld_handler): Call + SIGNAL_THREAD_CHECK. + + * data.c (arith_error): Call SIGNAL_THREAD_CHECK. + + * atimer.c (alarm_signal_handler): Call SIGNAL_THREAD_CHECK. + + * xterm.c (xg_scroll_callback): Update XG_LAST_SB_DATA before + returning when xg_ignore_gtk_scrollbar is true. + +2004-12-14 Kim F. Storm <storm@cua.dk> + + * keyboard.c (read_char): Save and restore echo_string when + handling input method. + +2004-12-13 Richard M. Stallman <rms@gnu.org> + + * eval.c (syms_of_eval) <quit-flag>: Doc fix. + + * keyboard.c (Vthrow_on_input): New variable. + (syms_of_keyboard): Defvar and initialize it. + (kbd_buffer_store_event_hold): Handle Vthrow_on_input. + + * lisp.h (QUIT): Check for Vthrow_on_input. + (Vthrow_on_input): Declare it. + +2004-12-13 Kim F. Storm <storm@cua.dk> + + * xdisp.c (set_iterator_to_next): Reset stop_charpos after display + vector. + +2004-12-12 Richard M. Stallman <rms@gnu.org> + + * indent.c (Fvertical_motion): Call move_it_by_lines even if LINES = 0. + + * minibuf.c (Fall_completions): Add var `zero' and use it in loop. + (Ftry_completion): Really use outer `zero'; eliminate inner one. + +2004-12-12 Kenichi Handa <handa@m17n.org> + + * term.c (encode_terminal_code): Fix previous change. + +2004-12-11 Stefan Monnier <monnier@iro.umontreal.ca> + + * keyboard.c (handle_async_input): Remove pthread mutex handling. + (input_available_signal): Move pthread thingy to !SYNC_INPUT branch. + + * syntax.c (Fforward_word): Avoid non-idempotent side-effects + in macro arguments. + + * minibuf.c (Ftry_completion, Fall_completions): Don't use + XFASTINT blindly. + + * emacs.c (main, Fdump_emacs): Don't touch malloc hooks if SYNC_INPUT. + +2004-12-11 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * w32term.c (x_calc_absolute_position): Remove calculation of + difference between inner and outer window. Don't subtract difference + for left and top calculations. + + * xterm.c (x_calc_absolute_position): Don't subtract outer_pixel_diff + for left and top calculations. Remove call to x_real_positions. + [Bug report by Drew Adams in November] + (x_check_expected_move): Do not set change_gravity to 1 when calling + x_set_offset. + 2004-12-08 Richard M. Stallman <rms@gnu.org> * xdisp.c (get_next_display_element): Use `escape-glyph' for @@ -17,8 +173,8 @@ * emacs.c (Fdump_emacs): Add ! defined (SYSTEM_MALLOC) around reset_malloc_hooks. - * keyboard.c (handle_async_input, input_available_signal): Add - ! defined (SYSTEM_MALLOC) around thread code. + * keyboard.c (handle_async_input, input_available_signal): + Add ! defined (SYSTEM_MALLOC) around thread code. * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC. @@ -56,12 +212,11 @@ * emacs.c (Fdump_emacs): Call reset_malloc_hooks. * keyboard.c: Conditionally include pthread.h - (handle_async_inpu, input_available_signalt): If not in the main + (handle_async_input, input_available_signalt): If not in the main thread, block signal, send signal to main thread and return. * gtkutil.c (xg_get_file_with_chooser): Handle local files only. - Set current folder in file chooser if default_filename is a - directory. + Set current folder in file chooser if default_filename is a directory. 2004-12-05 Stefan Monnier <monnier@iro.umontreal.ca> @@ -92,6 +247,7 @@ * eval.c (Fcalled_interactively_p): Don't check INTERACTIVE. (interactive_p): Skip Scalled_interactively_p frames like Sinteractive_p frames. + (unwind_to_catch): Clear handling_signal. * data.c (Fmake_variable_buffer_local): Doc fix. (Fmake_local_variable): Doc fix. diff --git a/src/alloc.c b/src/alloc.c index 4cf5de46d21..7a6a1344d6c 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -99,7 +99,7 @@ extern __malloc_size_t __malloc_extra_blocks; If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* functions below are called from malloc, there is a chance that one of these threads preempts the Emacs main thread and the hook variables - end up in a inconsistent state. So we have a mutex to prevent that (note + end up in an inconsistent state. So we have a mutex to prevent that (note that the backend handles concurrent access to malloc within its own threads but Emacs code running in the main thread is not included in that control). @@ -109,7 +109,6 @@ extern __malloc_size_t __malloc_extra_blocks; To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ static pthread_mutex_t alloc_mutex; -pthread_t main_thread; #define BLOCK_INPUT_ALLOC \ do \ @@ -201,12 +200,6 @@ extern #endif /* VIRT_ADDR_VARIES */ int malloc_sbrk_unused; -/* Two limits controlling how much undo information to keep. */ - -EMACS_INT undo_limit; -EMACS_INT undo_strong_limit; -EMACS_INT undo_outer_limit; - /* Number of live and free conses etc. */ static int total_conses, total_markers, total_symbols, total_vector_size; @@ -1311,8 +1304,6 @@ uninterrupt_malloc () pthread_mutexattr_init (&attr); pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init (&alloc_mutex, &attr); - - main_thread = pthread_self (); #endif /* HAVE_GTK_AND_PTHREAD */ if (__free_hook != emacs_blocked_free) @@ -4648,13 +4639,48 @@ returns nil, because real GC can't be done. */) if (abort_on_gc) abort (); - EMACS_GET_TIME (t1); - /* Can't GC if pure storage overflowed because we can't determine if something is a pure object or not. */ if (pure_bytes_used_before_overflow) return Qnil; + /* Don't keep undo information around forever. + Do this early on, so it is no problem if the user quits. */ + { + register struct buffer *nextb = all_buffers; + + while (nextb) + { + /* If a buffer's undo list is Qt, that means that undo is + turned off in that buffer. Calling truncate_undo_list on + Qt tends to return NULL, which effectively turns undo back on. + So don't call truncate_undo_list if undo_list is Qt. */ + if (! EQ (nextb->undo_list, Qt)) + truncate_undo_list (nextb); + + /* Shrink buffer gaps, but skip indirect and dead buffers. */ + if (nextb->base_buffer == 0 && !NILP (nextb->name)) + { + /* If a buffer's gap size is more than 10% of the buffer + size, or larger than 2000 bytes, then shrink it + accordingly. Keep a minimum size of 20 bytes. */ + int size = min (2000, max (20, (nextb->text->z_byte / 10))); + + if (nextb->text->gap_size > size) + { + struct buffer *save_current = current_buffer; + current_buffer = nextb; + make_gap (-(nextb->text->gap_size - size)); + current_buffer = save_current; + } + } + + nextb = nextb->next; + } + } + + EMACS_GET_TIME (t1); + /* In case user calls debug_print during GC, don't let that cause a recursive GC. */ consing_since_gc = 0; @@ -4693,42 +4719,6 @@ returns nil, because real GC can't be done. */) shrink_regexp_cache (); - /* Don't keep undo information around forever. */ - { - register struct buffer *nextb = all_buffers; - - while (nextb) - { - /* If a buffer's undo list is Qt, that means that undo is - turned off in that buffer. Calling truncate_undo_list on - Qt tends to return NULL, which effectively turns undo back on. - So don't call truncate_undo_list if undo_list is Qt. */ - if (! EQ (nextb->undo_list, Qt)) - nextb->undo_list - = truncate_undo_list (nextb->undo_list, undo_limit, - undo_strong_limit, undo_outer_limit); - - /* Shrink buffer gaps, but skip indirect and dead buffers. */ - if (nextb->base_buffer == 0 && !NILP (nextb->name)) - { - /* If a buffer's gap size is more than 10% of the buffer - size, or larger than 2000 bytes, then shrink it - accordingly. Keep a minimum size of 20 bytes. */ - int size = min (2000, max (20, (nextb->text->z_byte / 10))); - - if (nextb->text->gap_size > size) - { - struct buffer *save_current = current_buffer; - current_buffer = nextb; - make_gap (-(nextb->text->gap_size - size)); - current_buffer = save_current; - } - } - - nextb = nextb->next; - } - } - gc_in_progress = 1; /* clear_marks (); */ @@ -6004,29 +5994,6 @@ prevent garbage collection during a part of the program. */); doc: /* Non-nil means loading Lisp code in order to dump an executable. This means that certain objects should be allocated in shared (pure) space. */); - DEFVAR_INT ("undo-limit", &undo_limit, - doc: /* Keep no more undo information once it exceeds this size. -This limit is applied when garbage collection happens. -The size is counted as the number of bytes occupied, -which includes both saved text and other data. */); - undo_limit = 20000; - - DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, - doc: /* Don't keep more than this much size of undo information. -A previous command which pushes the undo list past this size -is entirely forgotten when GC happens. -The size is counted as the number of bytes occupied, -which includes both saved text and other data. */); - undo_strong_limit = 30000; - - DEFVAR_INT ("undo-outer-limit", &undo_outer_limit, - doc: /* Don't keep more than this much size of undo information. -If the current command has produced more than this much undo information, -GC discards it. This is a last-ditch limit to prevent memory overflow. -The size is counted as the number of bytes occupied, -which includes both saved text and other data. */); - undo_outer_limit = 300000; - DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, doc: /* Non-nil means display messages at start and end of garbage collection. */); garbage_collection_messages = 0; diff --git a/src/atimer.c b/src/atimer.c index 7410cad0244..ff5b8faaf36 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -364,6 +364,8 @@ alarm_signal_handler (signo) { EMACS_TIME now; + SIGNAL_THREAD_CHECK (signo); + EMACS_GET_TIME (now); pending_atimers = 0; diff --git a/src/data.c b/src/data.c index afbca80181d..811619b58b3 100644 --- a/src/data.c +++ b/src/data.c @@ -3366,6 +3366,7 @@ arith_error (signo) sigsetmask (SIGEMPTYMASK); #endif /* not BSD4_1 */ + SIGNAL_THREAD_CHECK (signo); Fsignal (Qarith_error, Qnil); } diff --git a/src/dispnew.c b/src/dispnew.c index f2fac47a7c2..6813cda5a71 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -6005,6 +6005,9 @@ window_change_signal (signalnum) /* If we don't have an argument, */ struct tty_display_info *tty; + signal (SIGWINCH, window_change_signal); + SIGNAL_THREAD_CHECK (signalnum); + /* The frame size change obviously applies to a single termcap-controlled terminal, but we can't decide which. Therefore, we resize the frames corresponding to each tty. @@ -6028,7 +6031,6 @@ window_change_signal (signalnum) /* If we don't have an argument, */ } } - signal (SIGWINCH, window_change_signal); errno = old_errno; } #endif /* SIGWINCH */ diff --git a/src/emacs.c b/src/emacs.c index fb7c573836a..b16ea78b9b8 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -343,6 +343,14 @@ int fatal_error_in_progress; void (*fatal_error_signal_hook) P_ ((void)); +#ifdef HAVE_GTK_AND_PTHREAD +/* When compiled with GTK and running under Gnome, multiple threads meay be + created. Keep track of our main thread to make sure signals are delivered + to it (see syssignal.h). */ + +pthread_t main_thread; +#endif + #ifdef SIGUSR1 SIGTYPE @@ -351,6 +359,7 @@ handle_USR1_signal (sig) { struct input_event buf; + SIGNAL_THREAD_CHECK (sig); bzero (&buf, sizeof buf); buf.kind = USER_SIGNAL_EVENT; buf.frame_or_window = selected_frame; @@ -366,6 +375,7 @@ handle_USR2_signal (sig) { struct input_event buf; + SIGNAL_THREAD_CHECK (sig); bzero (&buf, sizeof buf); buf.kind = USER_SIGNAL_EVENT; buf.code = 1; @@ -380,6 +390,7 @@ SIGTYPE fatal_error_signal (sig) int sig; { + SIGNAL_THREAD_CHECK (sig); fatal_error_code = sig; signal (sig, SIG_DFL); @@ -419,6 +430,7 @@ memory_warning_signal (sig) int sig; { signal (sig, memory_warning_signal); + SIGNAL_THREAD_CHECK (sig); malloc_warning ("Operating system warns that virtual memory is running low.\n"); @@ -1024,10 +1036,16 @@ main (argc, argv Also call realloc and free for consistency. */ free (realloc (malloc (4), 4)); +# ifndef SYNC_INPUT /* Arrange to disable interrupt input inside malloc etc. */ uninterrupt_malloc (); +# endif /* not SYNC_INPUT */ #endif /* not SYSTEM_MALLOC */ +#ifdef HAVE_GTK_AND_PTHREAD + main_thread = pthread_self (); +#endif /* HAVE_GTK_AND_PTHREAD */ + #if defined (MSDOS) || defined (WINDOWSNT) /* We do all file input/output as binary files. When we need to translate newlines, we do that manually. */ @@ -1116,7 +1134,10 @@ main (argc, argv /* Handle the -batch switch, which means don't do interactive display. */ noninteractive = 0; if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args)) - noninteractive = 1; + { + noninteractive = 1; + Vundo_outer_limit = Qnil; + } if (argmatch (argv, argc, "-script", "--script", 3, &junk, &skip_args)) { noninteractive = 1; /* Set batch mode. */ @@ -2237,7 +2258,7 @@ You must run Emacs in batch mode in order to dump it. */) memory_warnings (my_edata, malloc_warning); #endif /* not WINDOWSNT */ #endif -#if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) +#if !defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT /* Pthread may call malloc before main, and then we will get an endless loop, because pthread_self (see alloc.c) calls malloc the first time it is called on some systems. */ diff --git a/src/eval.c b/src/eval.c index 0eb519fbfca..df528e3da80 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1178,6 +1178,7 @@ unwind_to_catch (catch, value) set_poll_suppress_count (catch->poll_suppress_count); interrupt_input_blocked = catch->interrupt_input_blocked; handling_signal = 0; + immediate_quit = 0; do { @@ -3331,7 +3332,11 @@ Emacs could overflow the real C stack, and crash. */); DEFVAR_LISP ("quit-flag", &Vquit_flag, doc: /* Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil. -Typing C-g sets `quit-flag' non-nil, regardless of `inhibit-quit'. */); +If the value is t, that means do an ordinary quit. +If the value equals `throw-on-input', that means quit by throwing +to the tag specified in `throw-on-input'; it's for handling `while-no-input'. +Typing C-g sets `quit-flag' to t, regardless of `inhibit-quit', +but `inhibit-quit' non-nil prevents anything from taking notice of that. */); Vquit_flag = Qnil; DEFVAR_LISP ("inhibit-quit", &Vinhibit_quit, diff --git a/src/fileio.c b/src/fileio.c index 587f36d537d..195cff2bc8c 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -230,6 +230,8 @@ extern int minibuf_level; extern int minibuffer_auto_raise; +extern int history_delete_duplicates; + /* These variables describe handlers that have "already" had a chance to handle the current operation. @@ -6385,7 +6387,13 @@ and `read-file-name-function'. */) if (replace_in_history) /* Replace what Fcompleting_read added to the history with what we will actually return. */ - XSETCAR (Fsymbol_value (Qfile_name_history), double_dollars (val)); + { + Lisp_Object val1 = double_dollars (val); + tem = Fsymbol_value (Qfile_name_history); + if (history_delete_duplicates) + XSETCDR (tem, Fdelete (val1, XCDR(tem))); + XSETCAR (tem, val1); + } else if (add_to_history) { /* Add the value to the history--but not if it matches @@ -6393,8 +6401,10 @@ and `read-file-name-function'. */) Lisp_Object val1 = double_dollars (val); tem = Fsymbol_value (Qfile_name_history); if (! CONSP (tem) || NILP (Fequal (XCAR (tem), val1))) - Fset (Qfile_name_history, - Fcons (val1, tem)); + { + if (history_delete_duplicates) tem = Fdelete (val1, tem); + Fset (Qfile_name_history, Fcons (val1, tem)); + } } return val; diff --git a/src/floatfns.c b/src/floatfns.c index 61879eabe39..8cd08106ef2 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -981,6 +981,7 @@ float_error (signo) signal (SIGILL, float_error); #endif /* BSD_SYSTEM */ + SIGNAL_THREAD_CHECK (signo); in_float = 0; Fsignal (Qarith_error, Fcons (float_error_arg, Qnil)); diff --git a/src/indent.c b/src/indent.c index 4efb5445f7e..7cfe53d80bb 100644 --- a/src/indent.c +++ b/src/indent.c @@ -2094,8 +2094,9 @@ whether or not it is currently displayed in some window. */) move_it_by_lines (&it, -1, 0); it.vpos = 0; - if (XINT (lines) != 0) - move_it_by_lines (&it, XINT (lines), 0); + /* Do this even if LINES is 0, so that we move back + to the beginning of the current line as we ought. */ + move_it_by_lines (&it, XINT (lines), 0); SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); } diff --git a/src/keyboard.c b/src/keyboard.c index 052ef2d38b7..122a8e6b025 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3038,6 +3038,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) /* Save the echo status. */ int saved_immediate_echo = current_kboard->immediate_echo; struct kboard *saved_ok_to_echo = ok_to_echo_at_next_pause; + Lisp_Object saved_echo_string = current_kboard->echo_string; int saved_echo_after_prompt = current_kboard->echo_after_prompt; #if 0 @@ -3092,6 +3093,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) cancel_echoing (); ok_to_echo_at_next_pause = saved_ok_to_echo; + current_kboard->echo_string = saved_echo_string; current_kboard->echo_after_prompt = saved_echo_after_prompt; if (saved_immediate_echo) echo_now (); @@ -3574,6 +3576,9 @@ event_to_kboard (event) } #endif + +Lisp_Object Vthrow_on_input; + /* Store an event obtained at interrupt level into kbd_buffer, fifo */ void @@ -3699,6 +3704,24 @@ kbd_buffer_store_event_hold (event, hold_quit) *kbd_store_ptr = *event; ++kbd_store_ptr; } + + /* If we're inside while-no-input, and this event qualifies + as input, set quit-flag to cause an interrupt. */ + if (!NILP (Vthrow_on_input) + && event->kind != FOCUS_IN_EVENT + && event->kind != HELP_EVENT + && event->kind != DEICONIFY_EVENT) + { + Vquit_flag = Vthrow_on_input; + /* If we're inside a function that wants immediate quits, + do it now. */ + if (immediate_quit && NILP (Vinhibit_quit)) + { + immediate_quit = 0; + sigfree (); + QUIT; + } + } } @@ -6849,24 +6872,6 @@ handle_async_input () #ifdef BSD4_1 extern int select_alarmed; #endif -#if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) - extern pthread_t main_thread; - if (pthread_self () != main_thread) - { - /* POSIX says any thread can receive the signal. On GNU/Linux that is - not true, but for other systems (FreeBSD at least) it is. So direct - the signal to the correct thread and block it from this thread. */ -#ifdef SIGIO - sigset_t new_mask; - - sigemptyset (&new_mask); - sigaddset (&new_mask, SIGIO); - pthread_sigmask (SIG_BLOCK, &new_mask, 0); - pthread_kill (main_thread, SIGIO); -#endif - return; - } -#endif interrupt_input_pending = 0; @@ -6895,22 +6900,6 @@ input_available_signal (signo) { /* Must preserve main program's value of errno. */ int old_errno = errno; -#if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) - extern pthread_t main_thread; - if (pthread_self () != main_thread) - { - /* POSIX says any thread can receive the signal. On GNU/Linux that is - not true, but for other systems (FreeBSD at least) it is. So direct - the signal to the correct thread and block it from this thread. */ - sigset_t new_mask; - - sigemptyset (&new_mask); - sigaddset (&new_mask, SIGIO); - pthread_sigmask (SIG_BLOCK, &new_mask, 0); - pthread_kill (main_thread, SIGIO); - return; - } -#endif /* HAVE_GTK_AND_PTHREAD */ #if defined (USG) && !defined (POSIX_SIGNALS) /* USG systems forget handlers when they are used; must reestablish each time */ @@ -6927,6 +6916,8 @@ input_available_signal (signo) #ifdef SYNC_INPUT interrupt_input_pending = 1; #else + + SIGNAL_THREAD_CHECK (signo); handle_async_input (); #endif @@ -10379,6 +10370,7 @@ handle_interrupt () char c; struct frame *sf = SELECTED_FRAME (); + SIGNAL_THREAD_CHECK (signalnum); cancel_echoing (); /* XXX This code needs to be revised for multi-tty support. */ @@ -11525,6 +11517,12 @@ Used during Emacs' startup. */); doc: /* *How long to display an echo-area message when the minibuffer is active. If the value is not a number, such messages don't time out. */); Vminibuffer_message_timeout = make_number (2); + + DEFVAR_LISP ("throw-on-input", &Vthrow_on_input, + doc: /* If non-nil, any keyboard input throws to this symbol. +The value of that variable is passed to `quit-flag' and later causes a +peculiar kind of quitting. */); + Vthrow_on_input = Qnil; } void diff --git a/src/lisp.h b/src/lisp.h index 8be6b910a5e..59ce03435f5 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1768,11 +1768,15 @@ extern char *stack_bottom; #ifdef SYNC_INPUT extern void handle_async_input P_ ((void)); extern int interrupt_input_pending; + #define QUIT \ do { \ if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ { \ + Lisp_Object flag = Vquit_flag; \ Vquit_flag = Qnil; \ + if (EQ (Vthrow_on_input, flag)) \ + Fthrow (Vthrow_on_input, Qnil); \ Fsignal (Qquit, Qnil); \ } \ else if (interrupt_input_pending) \ @@ -1785,7 +1789,10 @@ extern int interrupt_input_pending; do { \ if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ { \ + Lisp_Object flag = Vquit_flag; \ Vquit_flag = Qnil; \ + if (EQ (Vthrow_on_input, flag)) \ + Fthrow (Vthrow_on_input, Qnil); \ Fsignal (Qquit, Qnil); \ } \ } while (0) @@ -2876,6 +2883,7 @@ extern struct kboard *echo_kboard; extern void cancel_echoing P_ ((void)); extern Lisp_Object Qdisabled, QCfilter; extern Lisp_Object Vtty_erase_char, Vhelp_form, Vtop_level; +extern Lisp_Object Vthrow_on_input; extern int input_pending; EXFUN (Fdiscard_input, 0); EXFUN (Frecursive_edit, 0); @@ -3041,7 +3049,7 @@ extern void syms_of_macros P_ ((void)); /* defined in undo.c */ extern Lisp_Object Qinhibit_read_only; EXFUN (Fundo_boundary, 0); -extern Lisp_Object truncate_undo_list P_ ((Lisp_Object, int, int, int)); +extern void truncate_undo_list P_ ((struct buffer *)); extern void record_marker_adjustment P_ ((Lisp_Object, int)); extern void record_insert P_ ((int, int)); extern void record_delete P_ ((int, Lisp_Object)); @@ -3050,6 +3058,7 @@ extern void record_change P_ ((int, int)); extern void record_property_change P_ ((int, int, Lisp_Object, Lisp_Object, Lisp_Object)); extern void syms_of_undo P_ ((void)); +extern Lisp_Object Vundo_outer_limit; /* defined in textprop.c */ extern Lisp_Object Qfont, Qmouse_face; diff --git a/src/macterm.c b/src/macterm.c index b0a7edeb516..da3dcb15ee8 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -5976,7 +5976,7 @@ mac_to_x_fontname (name, size, style, scriptcode, encoding_base) strcpy(cs, "mac-cyrillic"); break; case kTextEncodingMacCentralEurRoman: - strcpy(cs, "mac-centraleuropean"); + strcpy(cs, "mac-centraleurroman"); break; case kTextEncodingMacSymbol: case kTextEncodingMacDingbats: @@ -6034,7 +6034,7 @@ x_font_name_to_mac_font_name (char *xf, char *mf) coding_system = Qeuc_kr; else if (strcmp (cs, "mac-roman") == 0 || strcmp (cs, "mac-cyrillic") == 0 - || strcmp (cs, "mac-centraleuropean") == 0 + || strcmp (cs, "mac-centraleurroman") == 0 || strcmp (cs, "adobe-fontspecific") == 0) strcpy (mf, family); else @@ -6276,6 +6276,28 @@ static int xlfd_scalable_fields[] = }; static Lisp_Object +mac_c_string_match (regexp, string, nonspecial, exact) + Lisp_Object regexp; + const char *string, *nonspecial; + int exact; +{ + if (exact) + { + if (strcmp (string, nonspecial) == 0) + return build_string (string); + } + else if (strstr (string, nonspecial)) + { + Lisp_Object str = build_string (string); + + if (fast_string_match (regexp, str) >= 0) + return str; + } + + return Qnil; +} + +static Lisp_Object mac_do_list_fonts (pattern, maxnames) char *pattern; int maxnames; @@ -6286,6 +6308,8 @@ mac_do_list_fonts (pattern, maxnames) char scaled[256]; char *ptr; int scl_val[XLFD_SCL_LAST], *field, *val; + char *longest_start, *cur_start, *nonspecial; + int longest_len, cur_len, exact; for (i = 0; i < XLFD_SCL_LAST; i++) scl_val[i] = -1; @@ -6343,34 +6367,66 @@ mac_do_list_fonts (pattern, maxnames) ptr = regex; *ptr++ = '^'; - /* Turn pattern into a regexp and do a regexp match. */ + longest_start = cur_start = ptr; + longest_len = cur_len = 0; + exact = 1; + + /* Turn pattern into a regexp and do a regexp match. Also find the + longest substring containing no special characters. */ for (; *pattern; pattern++) { - if (*pattern == '?') - *ptr++ = '.'; - else if (*pattern == '*') - { - *ptr++ = '.'; - *ptr++ = '*'; - } + if (*pattern == '?' || *pattern == '*') + { + if (cur_len > longest_len) + { + longest_start = cur_start; + longest_len = cur_len; + } + cur_len = 0; + exact = 0; + + if (*pattern == '?') + *ptr++ = '.'; + else /* if (*pattern == '*') */ + { + *ptr++ = '.'; + *ptr++ = '*'; + } + } else - *ptr++ = tolower (*pattern); + { + if (cur_len == 0) + cur_start = ptr; + cur_len++; + + *ptr++ = tolower (*pattern); + } } + + if (cur_len > longest_len) + { + longest_start = cur_start; + longest_len = cur_len; + } + *ptr = '$'; *(ptr + 1) = '\0'; + nonspecial = xmalloc (longest_len + 1); + strncpy (nonspecial, longest_start, longest_len); + nonspecial[longest_len] = '\0'; + pattern_regex = build_string (regex); for (i = 0; i < font_name_count; i++) { - fontname = build_string (font_name_table[i]); - if (fast_string_match (pattern_regex, fontname) >= 0) + fontname = mac_c_string_match (pattern_regex, font_name_table[i], + nonspecial, exact); + if (!NILP (fontname)) { font_list = Fcons (fontname, font_list); - - n_fonts++; - if (maxnames > 0 && n_fonts >= maxnames) - break; + if (exact || maxnames > 0 && ++n_fonts >= maxnames) + break; } else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 && (ptr = strstr (font_name_table[i], "-0-0-75-75-m-0-"))) @@ -6384,17 +6440,19 @@ mac_do_list_fonts (pattern, maxnames) scl_val[XLFD_SCL_POINT_SIZE], scl_val[XLFD_SCL_AVGWIDTH], ptr + sizeof ("-0-0-75-75-m-0-") - 1); - fontname = build_string (scaled); - if (fast_string_match (pattern_regex, fontname) >= 0) + fontname = mac_c_string_match (pattern_regex, scaled, + nonspecial, exact); + if (!NILP (fontname)) { font_list = Fcons (fontname, font_list); - - n_fonts++; - if (maxnames > 0 && n_fonts >= maxnames) + if (exact || maxnames > 0 && ++n_fonts >= maxnames) break; } } } + + xfree (nonspecial); + return font_list; } diff --git a/src/minibuf.c b/src/minibuf.c index 375fa3622b3..463c083cb5e 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1232,6 +1232,7 @@ is used to further constrain the set of candidates. */) return call3 (alist, string, predicate, Qnil); bestmatch = bucket = Qnil; + zero = make_number (0); /* If ALIST is not a list, set TAIL just for gc pro. */ tail = alist; @@ -1258,7 +1259,7 @@ is used to further constrain the set of candidates. */) } else if (type == 2) { - if (XFASTINT (bucket) != 0) + if (!EQ (bucket, zero)) { elt = bucket; eltstring = Fsymbol_name (elt); @@ -1290,16 +1291,14 @@ is used to further constrain the set of candidates. */) if (STRINGP (eltstring) && SCHARS (string) <= SCHARS (eltstring) - && (tem = Fcompare_strings (eltstring, make_number (0), + && (tem = Fcompare_strings (eltstring, zero, make_number (SCHARS (string)), - string, make_number (0), Qnil, + string, zero, Qnil, completion_ignore_case ? Qt : Qnil), EQ (Qt, tem))) { /* Yes. */ Lisp_Object regexps; - Lisp_Object zero; - XSETFASTINT (zero, 0); /* Ignore this element if it fails to match all the regexps. */ { @@ -1353,9 +1352,9 @@ is used to further constrain the set of candidates. */) else { compare = min (bestmatchsize, SCHARS (eltstring)); - tem = Fcompare_strings (bestmatch, make_number (0), + tem = Fcompare_strings (bestmatch, zero, make_number (compare), - eltstring, make_number (0), + eltstring, zero, make_number (compare), completion_ignore_case ? Qt : Qnil); if (EQ (tem, Qt)) @@ -1386,15 +1385,15 @@ is used to further constrain the set of candidates. */) ((matchsize == SCHARS (eltstring)) == (matchsize == SCHARS (bestmatch)) - && (tem = Fcompare_strings (eltstring, make_number (0), + && (tem = Fcompare_strings (eltstring, zero, make_number (SCHARS (string)), - string, make_number (0), + string, zero, Qnil, Qnil), EQ (Qt, tem)) - && (tem = Fcompare_strings (bestmatch, make_number (0), + && (tem = Fcompare_strings (bestmatch, zero, make_number (SCHARS (string)), - string, make_number (0), + string, zero, Qnil, Qnil), ! EQ (Qt, tem)))) @@ -1481,13 +1480,14 @@ are ignored unless STRING itself starts with a space. */) || NILP (XCAR (alist)))); int index = 0, obsize = 0; int bindcount = -1; - Lisp_Object bucket, tem; + Lisp_Object bucket, tem, zero; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; CHECK_STRING (string); if (type == 0) return call3 (alist, string, predicate, Qt); allmatches = bucket = Qnil; + zero = make_number (0); /* If ALIST is not a list, set TAIL just for gc pro. */ tail = alist; @@ -1514,7 +1514,7 @@ are ignored unless STRING itself starts with a space. */) } else if (type == 2) { - if (XFASTINT (bucket) != 0) + if (!EQ (bucket, zero)) { elt = bucket; eltstring = Fsymbol_name (elt); @@ -1552,9 +1552,9 @@ are ignored unless STRING itself starts with a space. */) && SREF (string, 0) == ' ') || SREF (eltstring, 0) != ' ' || NILP (hide_spaces)) - && (tem = Fcompare_strings (eltstring, make_number (0), + && (tem = Fcompare_strings (eltstring, zero, make_number (SCHARS (string)), - string, make_number (0), + string, zero, make_number (SCHARS (string)), completion_ignore_case ? Qt : Qnil), EQ (Qt, tem))) diff --git a/src/process.c b/src/process.c index 65dec1457b0..646b9aed6a8 100644 --- a/src/process.c +++ b/src/process.c @@ -5104,6 +5104,7 @@ Lisp_Object process_sent_to; SIGTYPE send_process_trap () { + SIGNAL_THREAD_CHECK (SIGPIPE); #ifdef BSD4_1 sigrelse (SIGPIPE); sigrelse (SIGALRM); @@ -6146,6 +6147,8 @@ sigchld_handler (signo) register struct Lisp_Process *p; extern EMACS_TIME *input_available_clear_time; + SIGNAL_THREAD_CHECK (signo); + #ifdef BSD4_1 extern int sigheld; sigheld |= sigbit (SIGCHLD); diff --git a/src/regex.c b/src/regex.c index 1009c837dcf..a223f170765 100644 --- a/src/regex.c +++ b/src/regex.c @@ -5860,7 +5860,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) PREFETCH_NOLIMIT (); c2 = RE_STRING_CHAR (d, dend - d); #ifdef emacs - UPDATE_SYNTAX_TABLE_FORWARD (charpos); + UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1); #endif s2 = SYNTAX (c2); @@ -5947,7 +5947,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) PREFETCH_NOLIMIT (); c2 = RE_STRING_CHAR (d, dend - d); #ifdef emacs - UPDATE_SYNTAX_TABLE_FORWARD (charpos); + UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1); #endif s2 = SYNTAX (c2); diff --git a/src/syntax.c b/src/syntax.c index 8bfa62b49fc..fa34c2433c1 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1295,6 +1295,7 @@ and the function returns nil. Field boundaries are not noticed if (arg) Lisp_Object arg; { + Lisp_Object tmp; int orig_val, val; if (NILP (arg)) @@ -1307,8 +1308,9 @@ and the function returns nil. Field boundaries are not noticed if val = XINT (arg) > 0 ? ZV : BEGV; /* Avoid jumping out of an input field. */ - val = XFASTINT (Fconstrain_to_field (make_number (val), make_number (PT), - Qt, Qnil, Qnil)); + tmp = Fconstrain_to_field (make_number (val), make_number (PT), + Qt, Qnil, Qnil); + val = XFASTINT (tmp); SET_PT (val); return val == orig_val ? Qt : Qnil; diff --git a/src/sysdep.c b/src/sysdep.c index fb7b9275fc7..55b333bfbc9 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -2567,6 +2567,7 @@ select_alarm () #else /* not BSD4_1 */ signal (SIGALRM, SIG_IGN); #endif /* not BSD4_1 */ + SIGNAL_THREAD_CHECK (SIGALRM); if (read_alarm_should_throw) longjmp (read_alarm_throw, 1); } diff --git a/src/syssignal.h b/src/syssignal.h index 8d58325c02c..ab61d111398 100644 --- a/src/syssignal.h +++ b/src/syssignal.h @@ -20,6 +20,11 @@ Boston, MA 02111-1307, USA. */ extern void init_signals P_ ((void)); +#ifdef HAVE_GTK_AND_PTHREAD +#include <pthread.h> +extern pthread_t main_thread; +#endif + #ifdef POSIX_SIGNALS /* Don't #include <signal.h>. That header should always be #included @@ -199,5 +204,27 @@ extern SIGMASKTYPE sigprocmask_set; char *strsignal (); #endif +#ifdef HAVE_GTK_AND_PTHREAD +#define SIGNAL_THREAD_CHECK(signo) \ + do { \ + if (pthread_self () != main_thread) \ + { \ + /* POSIX says any thread can receive the signal. On GNU/Linux \ + that is not true, but for other systems (FreeBSD at least) \ + it is. So direct the signal to the correct thread and block \ + it from this thread. */ \ + sigset_t new_mask; \ + \ + sigemptyset (&new_mask); \ + sigaddset (&new_mask, signo); \ + pthread_sigmask (SIG_BLOCK, &new_mask, 0); \ + pthread_kill (main_thread, signo); \ + return; \ + } \ + } while (0) + +#else /* not HAVE_GTK_AND_PTHREAD */ +#define SIGNAL_THREAD_CHECK(signo) +#endif /* not HAVE_GTK_AND_PTHREAD */ /* arch-tag: 4580e86a-340d-4574-9e11-a742b6e1a152 (do not change this comment) */ diff --git a/src/term.c b/src/term.c index cf79ea43531..fc60b993ea4 100644 --- a/src/term.c +++ b/src/term.c @@ -640,11 +640,11 @@ encode_terminal_code (src, src_len, coding) required = MAX_MULTIBYTE_LENGTH * src_len; if (encode_terminal_bufsize < required) { - encode_terminal_bufsize = required; if (encode_terminal_bufsize == 0) encode_terminal_buf = xmalloc (required); else encode_terminal_buf = xrealloc (encode_terminal_buf, required); + encode_terminal_bufsize = required; } buf = encode_terminal_buf; diff --git a/src/undo.c b/src/undo.c index 9fdc46a3b13..df4b8d08cd6 100644 --- a/src/undo.c +++ b/src/undo.c @@ -24,6 +24,17 @@ Boston, MA 02111-1307, USA. */ #include "buffer.h" #include "commands.h" +/* Limits controlling how much undo information to keep. */ + +EMACS_INT undo_limit; +EMACS_INT undo_strong_limit; + +Lisp_Object Vundo_outer_limit; + +/* Function to call when undo_outer_limit is exceeded. */ + +Lisp_Object Vundo_outer_limit_function; + /* Last buffer for which undo information was recorded. */ Lisp_Object last_undo_buffer; @@ -291,31 +302,35 @@ but another undo command will undo to the previous boundary. */) } /* At garbage collection time, make an undo list shorter at the end, - returning the truncated list. - MINSIZE, MAXSIZE and LIMITSIZE are the limits on size allowed, - as described below. - In practice, these are the values of undo-limit, - undo-strong-limit, and undo-outer-limit. */ - -Lisp_Object -truncate_undo_list (list, minsize, maxsize, limitsize) - Lisp_Object list; - int minsize, maxsize, limitsize; + returning the truncated list. How this is done depends on the + variables undo-limit, undo-strong-limit and undo-outer-limit. + In some cases this works by calling undo-outer-limit-function. */ + +void +truncate_undo_list (b) + struct buffer *b; { + Lisp_Object list; Lisp_Object prev, next, last_boundary; int size_so_far = 0; + /* Make sure that calling undo-outer-limit-function + won't cause another GC. */ + int count = inhibit_garbage_collection (); + + /* Make the buffer current to get its local values of variables such + as undo_limit. Also so that Vundo_outer_limit_function can + tell which buffer to operate on. */ + record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + set_buffer_internal (b); + + list = b->undo_list; + prev = Qnil; next = list; last_boundary = Qnil; - /* Always preserve at least the most recent undo record - unless it is really horribly big. - If the first element is an undo boundary, skip past it. - - Skip, skip, skip the undo, skip, skip, skip the undo, - Skip, skip, skip the undo, skip to the undo bound'ry. - (Get it? "Skip to my Loo?") */ + /* If the first element is an undo boundary, skip past it. */ if (CONSP (next) && NILP (XCAR (next))) { /* Add in the space occupied by this element and its chain link. */ @@ -326,6 +341,12 @@ truncate_undo_list (list, minsize, maxsize, limitsize) next = XCDR (next); } + /* Always preserve at least the most recent undo record + unless it is really horribly big. + + Skip, skip, skip the undo, skip, skip, skip the undo, + Skip, skip, skip the undo, skip to the undo bound'ry. */ + while (CONSP (next) && ! NILP (XCAR (next))) { Lisp_Object elt; @@ -341,35 +362,53 @@ truncate_undo_list (list, minsize, maxsize, limitsize) + SCHARS (XCAR (elt))); } - /* If we reach LIMITSIZE before the first boundary, - we're heading for memory full, so truncate the list to nothing. */ - if (size_so_far > limitsize) - return Qnil; - /* Advance to next element. */ prev = next; next = XCDR (next); } + /* If by the first boundary we have already passed undo_outer_limit, + we're heading for memory full, so offer to clear out the list. */ + if (INTEGERP (Vundo_outer_limit) + && size_so_far > XINT (Vundo_outer_limit) + && !NILP (Vundo_outer_limit_function)) + { + Lisp_Object temp = last_undo_buffer; + + /* Normally the function this calls is undo-outer-limit-truncate. */ + if (! NILP (call1 (Vundo_outer_limit_function, + make_number (size_so_far)))) + { + /* The function is responsible for making + any desired changes in buffer-undo-list. */ + unbind_to (count, Qnil); + return; + } + /* That function probably used the minibuffer, and if so, that + changed last_undo_buffer. Change it back so that we don't + force next change to make an undo boundary here. */ + last_undo_buffer = temp; + } + if (CONSP (next)) last_boundary = prev; - /* Keep more if it fits. */ + /* Keep additional undo data, if it fits in the limits. */ while (CONSP (next)) { Lisp_Object elt; elt = XCAR (next); /* When we get to a boundary, decide whether to truncate - either before or after it. The lower threshold, MINSIZE, + either before or after it. The lower threshold, undo_limit, tells us to truncate after it. If its size pushes past - the higher threshold MAXSIZE as well, we truncate before it. */ + the higher threshold undo_strong_limit, we truncate before it. */ if (NILP (elt)) { - if (size_so_far > maxsize) + if (size_so_far > undo_strong_limit) break; last_boundary = prev; - if (size_so_far > minsize) + if (size_so_far > undo_limit) break; } @@ -390,16 +429,15 @@ truncate_undo_list (list, minsize, maxsize, limitsize) /* If we scanned the whole list, it is short enough; don't change it. */ if (NILP (next)) - return list; - + ; /* Truncate at the boundary where we decided to truncate. */ - if (!NILP (last_boundary)) - { - XSETCDR (last_boundary, Qnil); - return list; - } + else if (!NILP (last_boundary)) + XSETCDR (last_boundary, Qnil); + /* There's nothing we decided to keep, so clear it out. */ else - return Qnil; + b->undo_list = Qnil; + + unbind_to (count, Qnil); } DEFUN ("primitive-undo", Fprimitive_undo, Sprimitive_undo, 2, 2, 0, @@ -563,6 +601,54 @@ syms_of_undo () defsubr (&Sprimitive_undo); defsubr (&Sundo_boundary); + + DEFVAR_INT ("undo-limit", &undo_limit, + doc: /* Keep no more undo information once it exceeds this size. +This limit is applied when garbage collection happens. +When a previous command increases the total undo list size past this +value, the earlier commands that came before it are forgotten. + +The size is counted as the number of bytes occupied, +which includes both saved text and other data. */); + undo_limit = 20000; + + DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, + doc: /* Don't keep more than this much size of undo information. +This limit is applied when garbage collection happens. +When a previous command increases the total undo list size past this +value, that command and the earlier commands that came before it are forgotten. +However, the most recent buffer-modifying command's undo info +is never discarded for this reason. + +The size is counted as the number of bytes occupied, +which includes both saved text and other data. */); + undo_strong_limit = 30000; + + DEFVAR_LISP ("undo-outer-limit", &Vundo_outer_limit, + doc: /* Outer limit on size of undo information for one command. +At garbage collection time, if the current command has produced +more than this much undo information, it asks you whether to delete +the information. This is a last-ditch limit to prevent memory overflow. + +The size is counted as the number of bytes occupied, +which includes both saved text and other data. + +In fact, this calls the function which is the value of +`undo-outer-limit-function' with one argument, the size. +The text above describes the behavior of the function +that variable usually specifies. */); + Vundo_outer_limit = make_number (300000); + + DEFVAR_LISP ("undo-outer-limit-function", &Vundo_outer_limit_function, + doc: /* Function to call when an undo list exceeds `undo-outer-limit'. +This function is called with one argument, the current undo list size +for the most recent command (since the last undo boundary). +If the function returns t, that means truncation has been fully handled. +If it returns nil, the other forms of truncation are done. + +Garbage collection is inhibited around the call to this function, +so it must make sure not to do a lot of consing. */); + Vundo_outer_limit_function = Qnil; } /* arch-tag: d546ee01-4aed-4ffb-bb8b-eefaae50d38a diff --git a/src/w32term.c b/src/w32term.c index 0f6e9f67a66..e02019f45b9 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -5374,47 +5374,17 @@ void x_calc_absolute_position (f) struct frame *f; { - POINT pt; int flags = f->size_hint_flags; - pt.x = pt.y = 0; - - /* Find the position of the outside upper-left corner of - the inner window, with respect to the outer window. - But do this only if we will need the results. */ - if (f->output_data.w32->parent_desc != FRAME_W32_DISPLAY_INFO (f)->root_window) - { - BLOCK_INPUT; - MapWindowPoints (FRAME_W32_WINDOW (f), - f->output_data.w32->parent_desc, - &pt, 1); - UNBLOCK_INPUT; - } - - { - RECT rt; - rt.left = rt.right = rt.top = rt.bottom = 0; - - BLOCK_INPUT; - AdjustWindowRect(&rt, f->output_data.w32->dwStyle, - FRAME_EXTERNAL_MENU_BAR (f)); - UNBLOCK_INPUT; - - pt.x += (rt.right - rt.left); - pt.y += (rt.bottom - rt.top); - } - /* Treat negative positions as relative to the leftmost bottommost position that fits on the screen. */ if (flags & XNegative) f->left_pos = (FRAME_W32_DISPLAY_INFO (f)->width - - 2 * f->border_width - pt.x - FRAME_PIXEL_WIDTH (f) + f->left_pos); if (flags & YNegative) f->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height - - 2 * f->border_width - pt.y - FRAME_PIXEL_HEIGHT (f) + f->top_pos); /* The left_pos and top_pos diff --git a/src/xdisp.c b/src/xdisp.c index c58e8088141..b0a8f953c9c 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4914,7 +4914,9 @@ get_next_display_element (it) || (it->multibyte_p ? ((it->c >= 127 && it->len == 1) - || !CHAR_PRINTABLE_P (it->c)) + || !CHAR_PRINTABLE_P (it->c) + || it->c == 0x8ad + || it->c == 0x8a0) : (it->c >= 127 && (!unibyte_display_via_language_environment || it->c == unibyte_char_to_multibyte (it->c))))) @@ -4957,6 +4959,21 @@ get_next_display_element (it) XSETINT (it->ctl_chars[1], g); ctl_len = 2; } + else if (it->c == 0x8a0 || it->c == 0x8ad) + { + /* Set IT->ctl_chars[0] to the glyph for `\\'. */ + if (it->dp + && INTEGERP (DISP_ESCAPE_GLYPH (it->dp)) + && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (it->dp)))) + g = XINT (DISP_ESCAPE_GLYPH (it->dp)); + else + g = FAST_MAKE_GLYPH ('\\', face_id); + XSETINT (it->ctl_chars[0], g); + + g = FAST_MAKE_GLYPH (it->c == 0x8ad ? '-' : ' ', face_id); + XSETINT (it->ctl_chars[1], g); + ctl_len = 2; + } else { unsigned char str[MAX_MULTIBYTE_LENGTH]; @@ -5139,6 +5156,9 @@ set_iterator_to_next (it, reseat_p) it->dpvec = NULL; it->current.dpvec_index = -1; + /* Recheck faces after display vector */ + it->stop_charpos = 0; + /* Skip over characters which were displayed via IT->dpvec. */ if (it->dpvec_char_len < 0) reseat_at_next_visible_line_start (it, 1); diff --git a/src/xselect.c b/src/xselect.c index cd059e81979..1a033f1d973 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -2348,7 +2348,7 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal, Fcons (x_atom_to_symbol (display, type), Fcons (make_number (format), Qnil)))); - ret = (bytes ? make_string ((char *) data, bytes) : Qnil); + ret = (bytes ? make_unibyte_string ((char *) data, bytes) : Qnil); /* Use xfree, not XFree, because x_get_window_property calls xmalloc itself. */ xfree (data); diff --git a/src/xterm.c b/src/xterm.c index 480ee1c624a..51feed59ac4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -4286,8 +4286,6 @@ xg_scroll_callback (widget, data) int part = -1, whole = 0, portion = 0; GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (widget)); - if (xg_ignore_gtk_scrollbar) return; - position = gtk_adjustment_get_value (adj); p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA); @@ -4301,6 +4299,8 @@ xg_scroll_callback (widget, data) previous = *p; *p = position; + if (xg_ignore_gtk_scrollbar) return; + diff = (int) (position - previous); if (diff == (int) adj->step_increment) @@ -4332,7 +4332,7 @@ xg_scroll_callback (widget, data) } if (part >= 0) - { + { window_being_scrolled = bar->window; last_scroll_bar_part = part; x_send_scroll_bar_event (bar->window, part, portion, whole); @@ -8155,20 +8155,11 @@ x_calc_absolute_position (f) if (! ((flags & XNegative) || (flags & YNegative))) return; - /* Find the offsets of the outside upper-left corner of - the inner window, with respect to the outer window. - But do this only if we will need the results. */ - if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) - /* This is to get *_pixels_outer_diff. */ - x_real_positions (f, &win_x, &win_y); - /* Treat negative positions as relative to the leftmost bottommost position that fits on the screen. */ if (flags & XNegative) f->left_pos = (FRAME_X_DISPLAY_INFO (f)->width - - 2 * FRAME_X_OUTPUT (f)->x_pixels_outer_diff - - FRAME_PIXEL_WIDTH (f) - + f->left_pos); + - FRAME_PIXEL_WIDTH (f) + f->left_pos); { int height = FRAME_PIXEL_HEIGHT (f); @@ -8190,15 +8181,7 @@ x_calc_absolute_position (f) #endif if (flags & YNegative) - f->top_pos = (FRAME_X_DISPLAY_INFO (f)->height - - FRAME_X_OUTPUT (f)->y_pixels_outer_diff - - /* Assume the window manager decorations are the same size on - three sides, i.e. left, right and bottom. This is to - compensate for the bottom part. */ - - FRAME_X_OUTPUT (f)->x_pixels_outer_diff - - height - + f->top_pos); + f->top_pos = (FRAME_X_DISPLAY_INFO (f)->height - height + f->top_pos); } /* The left_pos and top_pos @@ -8314,7 +8297,9 @@ x_check_expected_move (f) FRAME_X_OUTPUT (f)->move_offset_left = expect_left - f->left_pos; FRAME_X_OUTPUT (f)->move_offset_top = expect_top - f->top_pos; - x_set_offset (f, expect_left, expect_top, 1); + f->left_pos = expect_left; + f->top_pos = expect_top; + x_set_offset (f, expect_left, expect_top, 0); } else if (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN) FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_B; |