From 9cfae822fb36dc4beb4d397c36c447d059c18ca7 Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 14 Aug 2022 22:34:41 +1200 Subject: * src/buffer.c (mode-line-format): Remove docs for obsolete %t construct This documentation had been previously removed in 1999 in [1] but was subsequently restored again in a different form in 2006 in [2] as the construct was still supported on some systems. However it looks like it hasn't done what that documentation indicated since [3] in 2011, and the final remnant of this functionality was removed in [4] in 2013; so it seems clear that it's no longer supported and shouldn't be documented now. [1] commit 08de62001945d4dd32a3d6af44da05804cb296d5 [2] commit dafbe726b89a36010f3f24bb1efe4ace0a5f7f0f [3] commit 05c652517317d10690aaf0a6aa0bc876382b9d82 [4] commit 8549f9e89bd9288c4c709d183a5bf8f07dbeed3d --- src/buffer.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index df1f5206668..3bcd387f0c5 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5143,7 +5143,6 @@ A string is printed verbatim in the mode line except for %-constructs: %P -- print percent of buffer above bottom of window, perhaps plus Top, or print Bottom or All. %n -- print Narrow if appropriate. - %t -- visited file is text or binary (if OS supports this distinction). %z -- print mnemonics of keyboard, terminal, and buffer coding systems. %Z -- like %z, but including the end-of-line format. %e -- print error message about full memory. -- cgit v1.2.1 From 207176e6b1c162dddebddcfb1ba7efd270d48b01 Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 14 Aug 2022 23:11:43 +1200 Subject: * src/buffer.c (mode-line-format): Document %o and %q constructs Missed from commit b0b02ca7f3e06d0f092df6f81babd1277bf93b0f. --- src/buffer.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 3bcd387f0c5..0c740775e5b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5139,9 +5139,12 @@ A string is printed verbatim in the mode line except for %-constructs: %C -- Like %c, but the leftmost column is displayed as one. %i -- print the size of the buffer. %I -- like %i, but use k, M, G, etc., to abbreviate. + %o -- print percent of window travel through buffer, or Top, Bot or All. %p -- print percent of buffer above top of window, or Top, Bot or All. %P -- print percent of buffer above bottom of window, perhaps plus Top, or print Bottom or All. + %q -- print percent of buffer above both the top and the bottom of the + window, separated by ‘-’, or ‘All’. %n -- print Narrow if appropriate. %z -- print mnemonics of keyboard, terminal, and buffer coding systems. %Z -- like %z, but including the end-of-line format. -- cgit v1.2.1 From 3e70b2213a4f3649639c41544f95ad35c1377755 Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 14 Aug 2022 22:34:41 +1200 Subject: * src/buffer.c (mode-line-format): Remove docs for obsolete %t construct This documentation had been previously removed in 1999 in [1] but was subsequently restored again in a different form in 2006 in [2] as the construct was still supported on some systems. However it looks like it hasn't done what that documentation indicated since [3] in 2011, and the final remnant of this functionality was removed in [4] in 2013; so it seems clear that it's no longer supported and shouldn't be documented now. [1] commit 08de62001945d4dd32a3d6af44da05804cb296d5 [2] commit dafbe726b89a36010f3f24bb1efe4ace0a5f7f0f [3] commit 05c652517317d10690aaf0a6aa0bc876382b9d82 [4] commit 8549f9e89bd9288c4c709d183a5bf8f07dbeed3d --- src/buffer.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index df1f5206668..3bcd387f0c5 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5143,7 +5143,6 @@ A string is printed verbatim in the mode line except for %-constructs: %P -- print percent of buffer above bottom of window, perhaps plus Top, or print Bottom or All. %n -- print Narrow if appropriate. - %t -- visited file is text or binary (if OS supports this distinction). %z -- print mnemonics of keyboard, terminal, and buffer coding systems. %Z -- like %z, but including the end-of-line format. %e -- print error message about full memory. -- cgit v1.2.1 From 73f186b0c9345ca386bce7f441589c3530685fae Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 14 Aug 2022 23:11:43 +1200 Subject: * src/buffer.c (mode-line-format): Document %o and %q constructs Missed from commit b0b02ca7f3e06d0f092df6f81babd1277bf93b0f. --- src/buffer.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 3bcd387f0c5..0c740775e5b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5139,9 +5139,12 @@ A string is printed verbatim in the mode line except for %-constructs: %C -- Like %c, but the leftmost column is displayed as one. %i -- print the size of the buffer. %I -- like %i, but use k, M, G, etc., to abbreviate. + %o -- print percent of window travel through buffer, or Top, Bot or All. %p -- print percent of buffer above top of window, or Top, Bot or All. %P -- print percent of buffer above bottom of window, perhaps plus Top, or print Bottom or All. + %q -- print percent of buffer above both the top and the bottom of the + window, separated by ‘-’, or ‘All’. %n -- print Narrow if appropriate. %z -- print mnemonics of keyboard, terminal, and buffer coding systems. %Z -- like %z, but including the end-of-line format. -- cgit v1.2.1 From 28db56d5f04879675aabb3fb2195ef2dd27716ba Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 14 Aug 2022 23:17:38 +1200 Subject: * src/buffer.c (mode-line-format): Reorder and reformat %-construct docs The original formatting dates back to the earliest commits. It saved a few lines but was harder to follow. As windows are typically taller now than the terminals of the time, this reformatting now makes better sense for readabiity. See bug#57080. * doc/lispref/modes.texi: Order change for consistency. Add index. --- src/buffer.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 0c740775e5b..31c08cf3650 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5124,35 +5124,38 @@ A list whose car is an integer is processed by processing the cadr of negative) to the width specified by that number. A string is printed verbatim in the mode line except for %-constructs: - %b -- print buffer name. %f -- print visited file name. - %F -- print frame name. - %* -- print %, * or hyphen. %+ -- print *, % or hyphen. - %& is like %*, but ignore read-only-ness. - % means buffer is read-only and * means it is modified. - For a modified read-only buffer, %* gives % and %+ gives *. - %s -- print process status. %l -- print the current line number. + %b -- print buffer name. %c -- print the current column number (this makes editing slower). Columns are numbered starting from the left margin, and the leftmost column is displayed as zero. To make the column number update correctly in all cases, - `column-number-mode' must be non-nil. + `column-number-mode' must be non-nil. %C -- Like %c, but the leftmost column is displayed as one. + %e -- print error message about full memory. + %f -- print visited file name. + %F -- print frame name. %i -- print the size of the buffer. %I -- like %i, but use k, M, G, etc., to abbreviate. + %l -- print the current line number. + %n -- print Narrow if appropriate. %o -- print percent of window travel through buffer, or Top, Bot or All. %p -- print percent of buffer above top of window, or Top, Bot or All. %P -- print percent of buffer above bottom of window, perhaps plus Top, or print Bottom or All. %q -- print percent of buffer above both the top and the bottom of the window, separated by ‘-’, or ‘All’. - %n -- print Narrow if appropriate. + %s -- print process status. %z -- print mnemonics of keyboard, terminal, and buffer coding systems. %Z -- like %z, but including the end-of-line format. - %e -- print error message about full memory. - %@ -- print @ or hyphen. @ means that default-directory is on a - remote machine. - %[ -- print one [ for each recursive editing level. %] similar. - %% -- print %. %- -- print infinitely many dashes. + %& -- print * if the buffer is modified, otherwise hyphen. + %+ -- print *, % or hyphen (modified, read-only, neither). + %* -- print %, * or hyphen (read-only, modified, neither). + For a modified read-only buffer, %+ prints * and %* prints %. + %@ -- print @ if default-directory is on a remote machine, else hyphen. + %[ -- print one [ for each recursive editing level. + %] -- print one ] for each recursive editing level. + %- -- print enough dashes to fill the mode line. + %% -- print %. Decimal digits after the % specify field width to which to pad. */); DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode), -- cgit v1.2.1 From 7e26a5c774e7c71782d89abe1d4be125d8422a4b Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Tue, 28 Mar 2023 23:06:55 +0000 Subject: Remove labeled restrictions before calling Fwiden * src/editfns.c (labeled_restrictions_remove_in_current_buffer): New function. * src/lisp.h: Make it externally visible. * src/xdisp.c (display_count_lines_logically): * src/lread.c (readevalloop): * src/indent.c (line_number_display_width): * src/fileio.c (write_region): * src/callproc.c (Fcall_process_region): * src/buffer.c (Ferase_buffer): Use it. --- src/buffer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 0c740775e5b..252231357bc 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2386,6 +2386,7 @@ Any narrowing restriction in effect (see `narrow-to-region') is removed, so the buffer is truly empty after this. */) (void) { + labeled_restrictions_remove_in_current_buffer (); Fwiden (); del_range (BEG, Z); -- cgit v1.2.1 From c60b59e04c3776a90adaa8c8fe53af3075a833b8 Mon Sep 17 00:00:00 2001 From: Mattias Engdegård Date: Fri, 14 Apr 2023 18:26:27 +0200 Subject: Disallow creation of circular variable alias chains Make `defvaralias` signal an error upon attempts to create variable alias cycles. This detects errors earlier and makes the alias traversal during execution simpler and faster since no cycle detection is needed elsewhere. Now variable and function aliases are handled identically in these respects. * src/lisp.h (indirect_variable): Remove declaration. * src/data.c (indirect_variable): Remove. (Findirect_variable): Update doc string. Simplify alias resolution. (Fboundp, find_symbol_value, set_internal, default_value) (set_default_internal, Fmake_variable_buffer_local) (Fmake_local_variable, Fkill_local_variable, Flocal_variable_p) (Flocal_variable_if_set_p, Fvariable_binding_locus): * src/buffer.c (buffer_local_value): * src/eval.c (specbind): Simplify variable alias resolution. (Fdefvaralias): Update doc string. Check for cycles. * doc/lispref/variables.texi (Variable Aliases): Mention that `defvaralias` can signal `cyclic-variable-indirection` but `indirect-variable` cannot. * etc/NEWS: Announce the change. * test/src/eval-tests.el (eval-tests-defvaralias): New test. --- src/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 31c08cf3650..3e3be805a6d 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1307,7 +1307,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer) start: switch (sym->u.s.redirect) { - case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start; case SYMBOL_PLAINVAL: result = SYMBOL_VAL (sym); break; case SYMBOL_LOCALIZED: { /* Look in local_var_alist. */ -- cgit v1.2.1 From 4fedd5af4cc53666277fbcfc3417c0d7e3201c1d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 14 May 2023 18:51:23 -0700 Subject: Work around GCC bug 109847 in buffer.c * src/buffer.c: Ignore GCC 13+ -Wanalyzer-out-of-bounds. --- src/buffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 399460c47da..7951b7ac322 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -50,6 +50,14 @@ along with GNU Emacs. If not, see . */ #include "w32heap.h" /* for mmap_* */ #endif +/* Work around GCC bug 109847 + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109847 + which causes GCC to mistakenly complain about + AUTO_STRING with "*scratch*". */ +#if GNUC_PREREQ (13, 0, 0) +# pragma GCC diagnostic ignored "-Wanalyzer-out-of-bounds" +#endif + /* This structure holds the default values of the buffer-local variables defined with DEFVAR_PER_BUFFER, that have special slots in each buffer. The default value occupies the same slot in this structure -- cgit v1.2.1 From 5ef169ed701fa4f850fdca5563cdd468207d5d4f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 17 May 2023 15:36:54 -0700 Subject: Prefer C23 ckd_* to Gnulib *_WRAPV macros C23 has added ckd_add etc. macros with functionality equivalent to the older Gnulib INT_ADD_WRAPV macros, so switch to the more-standard names. * admin/merge-gnulib (GNULIB_MODULES): Add stdckdint. This merely makes the dependency explicit, as we were already using this Gnulib module indirectly. * lib-src/etags.c, src/lisp.h: Include stdckdint.h. * lib-src/etags.c (xnmalloc, xnrealloc): * src/alloc.c (xnmalloc, xnrealloc, xpalloc, Fmake_string) (mark_memory): * src/bignum.c (emacs_mpz_pow_ui): * src/buffer.c (record_overlay_string, overlay_strings): * src/bytecode.c (exec_byte_code): * src/casefiddle.c (do_casify_multibyte_string): * src/ccl.c (ccl_driver, Fccl_execute_on_string): * src/character.c (char_width, c_string_width) (lisp_string_width, count_size_as_multibyte) (string_escape_byte8): * src/cmds.c (internal_self_insert): * src/coding.c (coding_alloc_by_realloc, produce_chars): * src/data.c (arith_driver): * src/dispnew.c (realloc_glyph_pool, init_display_interactive): * src/doprnt.c (parse_format_integer): * src/editfns.c (Freplace_buffer_contents, str2num) (styled_format): * src/emacs-module.c (module_global_reference_p) (module_make_global_ref, module_funcall): * src/eval.c (max_ensure_room): * src/fileio.c (blocks_to_bytes): * src/fns.c (Ffillarray): * src/font.c (font_intern_prop): * src/frame.c (check_frame_pixels): * src/gnutls.c (gnutls_hex_string, gnutls_symmetric_aead): * src/gtkutil.c (get_utf8_string): * src/haikuterm.c (haiku_term_init): * src/image.c (xbm_scan, image_to_emacs_colors) (image_detect_edges, png_load_body): * src/keyboard.c (Frecursion_depth): * src/keymap.c (Flookup_key, Fkey_description): * src/lisp.h (modiff_incr, SAFE_ALLOCA_LISP_EXTRA): * src/lread.c (read_bool_vector): * src/pgtkterm.c (pgtk_term_init): * src/regex-emacs.c (regex_compile): * src/term.c (encode_terminal_code): * src/termcap.c (tputs): * src/textconv.c (textconv_query): * src/timefns.c (timespec_ticks, lisp_time_hz_ticks) (Fdecode_time, check_tm_member): * src/tparam.c (tparam1): * src/w32term.c (w32_initialize_display_info): * src/xdisp.c (fill_column_indicator_column, decode_mode_spec): * src/xselect.c (selection_data_size, x_property_data_to_lisp): * src/xsmfns.c (smc_save_yourself_CB): * src/xterm.c (xm_setup_dnd_targets, x_sync_get_monotonic_time) (x_sync_current_monotonic_time, x_sync_note_frame_times) (x_display_set_last_user_time, x_term_init): Prefer the C23 stdckdint macros to their Gnulib intprops.h counterparts, since C23 is standard. --- src/buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 7951b7ac322..0c46b201586 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3343,7 +3343,7 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, else nbytes = SBYTES (str); - if (INT_ADD_WRAPV (ssl->bytes, nbytes, &nbytes)) + if (ckd_add (&nbytes, nbytes, ssl->bytes)) memory_full (SIZE_MAX); ssl->bytes = nbytes; @@ -3357,7 +3357,7 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, else nbytes = SBYTES (str2); - if (INT_ADD_WRAPV (ssl->bytes, nbytes, &nbytes)) + if (ckd_add (&nbytes, nbytes, ssl->bytes)) memory_full (SIZE_MAX); ssl->bytes = nbytes; } @@ -3429,7 +3429,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) unsigned char *p; ptrdiff_t total; - if (INT_ADD_WRAPV (overlay_heads.bytes, overlay_tails.bytes, &total)) + if (ckd_add (&total, overlay_heads.bytes, overlay_tails.bytes)) memory_full (SIZE_MAX); if (total > overlay_str_len) overlay_str_buf = xpalloc (overlay_str_buf, &overlay_str_len, -- cgit v1.2.1