Paul Eggert [Sun, 26 Apr 2020 22:18:49 +0000 (15:18 -0700)]
Improve string_char_and_length speed
This tweak improved the CPU time performance of
‘make compile-always’ by about 1.7% on my platform.
* src/character.c (string_char): Remove; no longer used.
* src/character.h (string_char_and_length): Redo so that it
needn’t call string_char. This helps the caller, which can now
become a leaf function.
Paul Eggert [Sat, 25 Apr 2020 23:17:25 +0000 (16:17 -0700)]
Inline a couple of functions that were macros
This reclaims a bit of performance when compiling with gcc -Og.
These functions were macros until I changed them in
2020-04-17T14:57:25Z!eggert@cs.ucla.edu.
* src/casefiddle.c (make_char_unibyte):
* src/ccl.c (GET_TRANSLATION_TABLE): Now inline.
45a64c97c7 (origin/emacs-27) Clarify semantics of trace-function CONT... 821760fdc4 Don't let a code literal get modified in mml parsing (Bug#... 74a92be16d * lisp/simple.el (kill-ring-save): Doc fix. (Bug#40797) 3d0e859692 Minor doc clarification regarding fringe bitmaps 4d86c7f822 Fix documentation of fringe bitmaps a76af88dd8 Tweak mutability doc a bit more f7e488d206 Calc: fix autoload errors (bug#40800) 369761b36d ; * src/xdisp.c: Improve the introductory commentary. a92ca1f177 Improve indexing of ELisp manual 5a25d17760 * lisp/image-mode.el (image-transform-resize): Remove FIXM... 37ebec3a95 Improve the default value of 'doc-view-ghostscript-program'. ba6104d1e8 Change doc-view-mode-map prefix key 's' to 'c'. 400ff5cd19 Improve wording about constants d2836fe71b Improve the default value of 'doc-view-ghostscript-program'. fc55f65305 Minor improvements in documentation of the last change a64da75961 Add image-auto-resize defcustoms to image-mode.el 692ad40539 Improve the documentation of tab-bar and tab-line
Eli Zaretskii [Sat, 25 Apr 2020 13:37:46 +0000 (16:37 +0300)]
Fix GDI+ image loading by file name
Without a call to image_find_image, we can get a file name that
is relative to data-directory/images/, or a file name that
starts with "~/", in which case w32_load_image would fail.
* src/image.c (native_image_load): Call image_find_image_file to
resolve and encode the image file name.
* src/w32image.c (w32_load_image): No need to encode the file
name, as it's already encoded by native_image_load.
* lisp/calc/calc-ext.el (calc-init-extensions):
Remove calc-kbd-report key binding and autoload; it was removed in 2005.
calc-keypad-x-{left,right,middle}-click were renamed to
calc-keypad-{left,right,middle}-click in 2001; fix the autoloads.
calc-twos-complement-mode is a variable, not a function; remove the
autoload.
* lisp/calc/calc-prog.el: Remove commented-out calc-kbd-report.
Alan Mackenzie [Fri, 24 Apr 2020 15:51:43 +0000 (15:51 +0000)]
Fix bug #40766, an error in edebug spec handling
Also remove some debris.
* lisp/emacs-lisp/edebug.el (edebug-spec): Move the entry for edebug-spec-list
to before that for vector in the &or form. This assures that in a dotted list
of vectors, that list gets handled correctly by edebug-spec-list rather than
wrongly by (vector ...).
(def-edebug-spec &key): Remove, since it is ill formed and superfluous.
Improve the default value of 'doc-view-ghostscript-program'.
* lisp/doc-view.el (doc-view-ghostscript-program): Use plain command
name instead of qualified name returned by executable-find (as
suggested by Stefan Monnier). (Bug#36357)
Eli Zaretskii [Thu, 23 Apr 2020 15:40:42 +0000 (18:40 +0300)]
Fix display of composed text with :box face attribute
* src/xdisp.c (get_next_display_element): For a composition on a
display or overlay string, set the end_of_box_run_p flag if the
string ends at the last character included in the composition.
(fill_gstring_glyph_string): Fix the way the width of a gstring
glyph string is calculated: use the values calculated in
gui_produce_glyphs, since the latter adjusts the width due to the
face's ':box' attribute.
* src/xterm.c (x_draw_glyph_string_box):
* src/w32term.c (w32_draw_glyph_string_box):
* src/nsterm.m (ns_dumpglyphs_box_or_relief): Support automatic
compositions, which have the right_box_line_p flag set on the last
glyph produced from the composition. (Bug#40687)
* src/w32term.c (w32_compute_glyph_string_overhangs): Update to be
consistent with xterm.c in its support of automatic composition
glyph strings.
* src/dispextern.h (enum glyph_type): More accurate commentary.
* src/.gdbinit (pgx): Display slice.img members only for image
glyphs.
Paul Eggert [Thu, 23 Apr 2020 02:00:08 +0000 (19:00 -0700)]
text-char-description minor cleanup
* src/keymap.c (push_text_char_description): Omit useless code.
(Ftext_char_description): Minor code cleanup, inspired by
seeing an incorrect comment about MAX_MULTIBYTE_LENGTH’s value.
Paul Eggert [Thu, 23 Apr 2020 01:58:45 +0000 (18:58 -0700)]
Tweak multibyte parsing loops
* src/character.c (parse_str_as_multibyte, str_as_multibyte):
Let the fast loop run a little longer, fixing what appears
to be an off-by-1 performance nit.
Paul Eggert [Wed, 22 Apr 2020 17:42:09 +0000 (10:42 -0700)]
Improve wording about constants
Thanks to Štěpán Němec and Drew Adams for reviews of recent changes.
* doc/lispref/eval.texi (Quoting): Give an example.
* doc/lispref/lists.texi (Association Lists): Simplify example code.
* doc/lispref/objects.texi (Lisp Data Types)
(Constants and Mutability): Clarify wording.
* lisp/net/tramp-smb.el (tramp-smb-conf): Fix docstring.
(tramp-smb-options): New defcustom.
(tramp-smb-handle-copy-directory, tramp-smb-handle-file-acl)
(tramp-smb-handle-set-file-acl, tramp-smb-maybe-open-connection):
Use it.
Paul Eggert [Tue, 21 Apr 2020 05:26:30 +0000 (22:26 -0700)]
Fix string-to-multibyte overlong sequence bug
* src/character.h (MULTIBYTE_LENGTH, MULTIBYTE_LENGTH_NO_CHECK):
Remove, replacing with ...
(multibyte_length): ... this new function. All callers changed.
The new function rejects overlong multibyte forms.
* test/src/buffer-tests.el (buffer-multibyte-overlong-sequences):
New test.
Juri Linkov [Mon, 20 Apr 2020 23:42:16 +0000 (02:42 +0300)]
Add image-auto-resize defcustoms to image-mode.el
* lisp/image-mode.el (image-auto-resize)
(image-auto-resize-on-window-resize): New defcustoms.
(image-mode-map): Bind "sb" to image-transform-fit-both.
(image-mode): Set image-transform-resize to image-auto-resize initially.
(image-mode--setup-mode): Add hook on image-auto-resize-on-window-resize.
(image-toggle-display-image): Check if image-transform-resize is t.
(image-transform-properties): Check image-transform-resize for nil and t.
(image-transform-fit-both): New command.
(image-transform-reset): Reset image-transform-resize to image-auto-resize.
* doc/emacs/files.texi (Image Mode): Mention image-auto-resize and
image-auto-resize-on-window-resize.
Eli Zaretskii [Mon, 20 Apr 2020 16:29:58 +0000 (19:29 +0300)]
Remove workaround from w32image.c
* src/w32image.c (w32_load_image): Remove a workaround for a bug
that is not needed anymore. This error was happening because
GDI+ functions were called as CDECL, not as STDCALL.
Paul Eggert [Sun, 19 Apr 2020 23:46:47 +0000 (16:46 -0700)]
Tweak setcar-related wording
* doc/lispref/eval.texi (Self-Evaluating Forms):
Change “primitives” to “operations”.
Problem reported by Štěpán Němec in:
https://lists.gnu.org/r/emacs-devel/2020-04/msg01146.html
Juri Linkov [Sun, 19 Apr 2020 23:07:43 +0000 (02:07 +0300)]
* lisp/image-mode.el: Add prefix key 's' and reduce dependency on ImageMagick.
* lisp/image-mode.el (image-mode-map): Regroup existing keybindings and
add new ones with the prefix key 's'.
Remove condition ":visible (eq image-type 'imagemagick)" from menu.
(image-toggle-display-image): Don't rotate again after user rotated manually.
(image-transform-check-size): Remove check for imagemagick.
(image-transform-properties, image-transform-set-scale)
(image-transform-fit-to-height, image-transform-fit-to-width)
(image-transform-set-rotation, image-transform-reset):
Remove mentions of ImageMagick from docstrings since these commands
now work without ImageMagick.
Paul Eggert [Sun, 19 Apr 2020 22:09:02 +0000 (15:09 -0700)]
Fix mutability glitches reported by Drew Adams
See Bug#40693#32.
* doc/lispref/eval.texi (Self-Evaluating Forms, Backquote):
Say that these yield constant conses, vectors and strings,
not constant symbols.
* doc/lispref/objects.texi (Constants and Mutability): Say that an
attempt to modify a constant variable signals an error, instead of
saying that it has undefined behavior.
Paul Eggert [Sun, 19 Apr 2020 19:00:49 +0000 (12:00 -0700)]
Improve mutability documentation
This change was inspired by comments from Štěpán Němec in:
https://lists.gnu.org/r/emacs-devel/2020-04/msg01063.html
* doc/lispref/objects.texi (Lisp Data Types): Mention mutability.
(Constants and mutability): New section.
* doc/lispintro/emacs-lisp-intro.texi (Lists diagrammed)
(Indent Tabs Mode): Improve wording.
* doc/lispref/eval.texi (Self-Evaluating Forms):
Say that they return constants.
* doc/lispref/lists.texi (Sets And Lists):
Fix memql mistake/confusion that I recently introduced.
Eli Zaretskii [Sun, 19 Apr 2020 18:09:20 +0000 (21:09 +0300)]
Rework how GDI+ functions are loaded dynamically in w32image.c
* src/w32image.c: Define correct WINGDIPAPI typedefs for GDI+
functions. We cannot use DEF_DLL_FN, since that is for functions
with C calling conventions, whereas GDI+ functions are __stdcall.
(gdiplus_init): Load functions from DLL manually, not via
LOAD_DLL_FN, as the latter is for __cdecl functions.
(w32_frame_delay): Initialize delay with a negative value, as zero
is a valid delay.
Eli Zaretskii [Sun, 19 Apr 2020 16:38:53 +0000 (19:38 +0300)]
Don't use Gnulib's explicit_bzero on MS-Windows
This is a preventive change, since Gnulib was recently changed
its explicit_bzero to call SecureZeroMemory on MS-Windows,
disregarding systems older than XP, which didn't have it.
* src/w32.c (explicit_bzero): New function.
* nt/mingw-cfg.site (ac_cv_func_explicit_bzero): Avoid using the
Gnulib replacement for explicit_bzero.
* nt/inc/ms-w32.h (explicit_bzero): Add prototype.
Remove #' and function quoting from lambda forms in manual
* doc/lispref/abbrevs.texi (Abbrev Expansion):
* doc/lispref/backups.texi (Reverting):
* doc/lispref/functions.texi (Mapping Functions):
* doc/lispref/help.texi (Accessing Documentation):
* doc/lispref/sequences.texi (Char-Tables):
* doc/lispref/syntax.texi (Categories):
* doc/lispref/text.texi (Sorting):
Remove function quoting from lambda in examples where it still occurs,
since examples should follow our best style and be consistent.
Paul Eggert [Sat, 18 Apr 2020 19:59:17 +0000 (12:59 -0700)]
Document constant vs mutable objects better
This patch builds on a suggested patch by Mattias Engdegård
and on further comments by Eli Zaretskii.
Original bug report by Kevin Vigouroux (Bug#40671).
* doc/lispintro/emacs-lisp-intro.texi (set & setq, Review)
(setcar, Lists diagrammed, Mail Aliases, Indent Tabs Mode):
setq is a special form, not a function or command.
* doc/lispintro/emacs-lisp-intro.texi (setcar):
* doc/lispref/lists.texi (Modifying Lists, Rearrangement):
* doc/lispref/sequences.texi (Sequence Functions)
(Array Functions, Vectors):
* doc/lispref/strings.texi (String Basics, Modifying Strings):
Mention mutable vs constant objects.
* doc/lispintro/emacs-lisp-intro.texi (setcar, setcdr)
(kill-new function, cons & search-fwd Review):
* doc/lispref/edebug.texi (Printing in Edebug):
* doc/lispref/keymaps.texi (Changing Key Bindings):
* doc/lispref/lists.texi (Setcar, Setcdr, Rearrangement)
(Sets And Lists, Association Lists, Plist Access):
* doc/lispref/sequences.texi (Sequence Functions)
(Array Functions):
* doc/lispref/strings.texi (Text Comparison):
Fix examples so that they do not try to change constants.
* lisp/apropos.el: Use lexical-binding and remove redundant
:group args.
(apropos-words-to-regexp, apropos): Tweak docstrings.
(apropos-value-internal): Replace '(if x (progn y))' with
'(when x y)'.
(apropos-format-plist): Add docstring and replace '(if x (progn y))'
with '(when x y)'.
* test/lisp/apropos-tests.el: New file with tests for apropos.el.
Mention 'spam-stat-process-directory-age' in the documentation
I was at a loss as to why my attempt to set up spam-stat seemed to
have no effect, only to find (digging in the code) that it was
ignoring most of the sample files due to this undocumented variable.
* doc/misc/gnus.texi (Creating a spam-stat dictionary): Document
the variable 'spam-stat-process-directory-age'. (bug#39780)
f3b62b6c62 (origin/emacs-27) Avoid crashes in regex-emacs.c due to GC 175c61c18b Fix "C-u M-!" when 'shell-command-dont-erase-buffer' is no... 6b297519b5 Fix cl-most-positive-float doc typo c36c5a3ded ; lisp/ldefs-boot.el: Update. 3876a60569 Fix a typo in calculator.el 9e832ba91b * lisp/erc/erc.el: Add URL to the new ERC page on the Emac...
145a151d62 Correct Fido-mode's backspacing of directories with spaces 660b9b8cfb Default completion-flex-nospace to nil fb5f616ae8 Improve an example in w32 FAQ
* src/w32image.c (w32_frame_delay): Don't try to compute frame
delay if GdipGetPropertyItemSize fails for PropertyTagFrameDelay.
(w32_load_image): Don't add 'delay' member to metadata if the
delay could not be determined.
Eli Zaretskii [Sat, 18 Apr 2020 09:01:26 +0000 (12:01 +0300)]
Fix "C-u M-!" when 'shell-command-dont-erase-buffer' is non-nil
* lisp/simple.el (shell-command-dont-erase-buffer): Clarify the
effect of the various values in the doc string.
(shell-command-save-pos-or-erase, shell-command): Don't move or
push point if the output will go to the current buffer.
(Bug#40690)
(shell-command): Mention 'shell-command-dont-erase-buffer' in the
doc string.
* test/lisp/simple-tests.el
(with-shell-command-dont-erase-buffer): Don't is shell quoting
'like this', as it doesn't work on MS-Windows; quote "like this"
instead.
(simple-tests-shell-command-dont-erase-buffer): Adapt the test to
the new modus operandi.
* doc/emacs/misc.texi (Single Shell): Document the effect of the
various values of 'shell-command-dont-erase-buffer'.
* etc/NEWS: Expand and reword the entry regarding changes in
'shell-command-dont-erase-buffer'.
Martin Rudalics [Sat, 18 Apr 2020 08:25:20 +0000 (10:25 +0200)]
Fix handling of child frames in prepare_menu_bars (Bug#40639)
* src/xdisp.c (prepare_menu_bars): Call gui_consider_frame_title
for child frames too (Bug#40639). Never try to update menu bar
of a child frame. Do not exclude child frames from updating tool
or tab bars.
Paul Eggert [Fri, 17 Apr 2020 21:09:01 +0000 (14:09 -0700)]
Port recent character.h changes to --with-wide-int
* src/fns.c (mapcar1):
* src/keymap.c (Fkey_description):
* src/syntax.c (scan_lists):
Prefer ptrdiff_t to EMACS_INT where either will do; this fixes
newly-introduced type errors on --with-wide-int platforms where
ptrdiff_t is narrower than EMACS_INT.
* src/keymap.c (Fkey_description): Rework for clarity; remove goto.
* src/syntax.c (scan_words, Fforward_comment, scan_lists)):
Fix unlikely integer overflow problems that can occur on
--with-wide-int platforms, and that were caught by the recent
character.h changes.
Paul Eggert [Fri, 17 Apr 2020 14:57:25 +0000 (07:57 -0700)]
Prefer more inline functions in character.h
* src/buffer.h (fetch_char_advance, fetch_char_advance_no_check)
(buf_next_char_len, next_char_len, buf_prev_char_len)
(prev_char_len, inc_both, dec_both): New inline functions,
replacing the old character.h macros FETCH_CHAR_ADVANCE,
FETCH_CHAR_ADVANCE_NO_CHECK, BUF_INC_POS, INC_POS, BUF_DEC_POS,
DEC_POS, INC_BOTH, DEC_BOTH respectively. All callers changed.
These new functions all assume buffer primitives and so need
to be here rather than in character.h.
* src/casefiddle.c (make_char_unibyte): New static function,
replacing the old MAKE_CHAR_UNIBYTE macro. All callers changed.
(do_casify_unibyte_string): Use SINGLE_BYTE_CHAR_P instead
of open-coding it.
* src/ccl.c (GET_TRANSLATION_TABLE): New static function,
replacing the old macro of the same name.
* src/character.c (string_char): Omit 2nd arg. 3rd arg can no
longer be NULL. All callers changed.
* src/character.h (SINGLE_BYTE_CHAR_P): Move up.
(MAKE_CHAR_UNIBYTE, MAKE_CHAR_MULTIBYTE, PREV_CHAR_BOUNDARY)
(STRING_CHAR_AND_LENGTH, STRING_CHAR_ADVANCE)
(FETCH_STRING_CHAR_ADVANCE)
(FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE)
(FETCH_STRING_CHAR_ADVANCE_NO_CHECK, FETCH_CHAR_ADVANCE)
(FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, INC_BOTH)
(DEC_BOTH, BUF_INC_POS, BUF_DEC_POS): Remove.
(make_char_multibyte): New static function, replacing
the old macro MAKE_CHAR_MULTIBYTE. All callers changed.
(CHAR_STRING_ADVANCE): Remove; all callers changed to use
CHAR_STRING.
(NEXT_CHAR_BOUNDARY): Remove; it was unused.
(raw_prev_char_len): New inline function, replacing the
old PREV_CHAR_BOUNDARY macro. All callers changed.
(string_char_and_length): New inline function, replacing the
old STRING_CHAR_AND_LENGTH macro. All callers changed.
(STRING_CHAR): Rewrite in terms of string_char_and_length.
(string_char_advance): New inline function, replacing the old
STRING_CHAR_ADVANCE macro. All callers changed.
(fetch_string_char_advance): New inline function, replacing the
old FETCH_STRING_CHAR_ADVANCE macro. All callers changed.
(fetch_string_char_as_multibyte_advance): New inline function,
replacing the old FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE macro.
All callers changed.
(fetch_string_char_advance_no_check): New inline function,
replacing the old FETCH_STRING_CHAR_ADVANCE_NO_CHECK macro. All
callers changed.
* src/regex-emacs.c (HEAD_ADDR_VSTRING): Remove; no longer used.
* src/syntax.c (scan_lists): Use dec_bytepos instead of
open-coding it.
* src/xdisp.c (string_char_and_length): Rename from
string_char_and_length to avoid name conflict with new function in
character.h. All callers changed.
Paul Eggert [Fri, 17 Apr 2020 14:57:25 +0000 (07:57 -0700)]
Prefer inline functions in character.h
In character.h, replace macros with inline functions or enums
when this is easy. This improves maintainability and
on my platform (Fedora 31 x86-64, gcc -O2) improved CPU
performance very slightly (0.3%) on ‘make compile-always’.
* src/buffer.h (SANE_TAB_WIDTH, CHARACTER_WIDTH):
Move here from character.h, and make them inline functions.
Tune CHARACTER_WIDTH so that ASCII_CHAR_WIDTH is no longer needed.
(sanitize_tab_width, sanitize_char_width):
Move here from character.h.
* src/character.h (MAX_CHAR, MAX_UNICODE_CHAR, MAX_1_BYTE_CHAR)
(MAX_2_BYTE_CHAR, MAX_3_BYTE_CHAR, MAX_4_BYTE_CHAR)
(MAX_5_BYTE_CHAR, MIN_MULTIBYTE_LEADING_CODE)
(MAX_MULTIBYTE_LEADING_CODE, MAX_MULTIBYTE_LENGTH):
Now enum constants instead of macros.
* src/character.h (CHAR_BYTES): Redo to avoid conditional branches.
(CHAR_BYTE8_P, BYTE8_TO_CHAR, UNIBYTE_TO_CHAR, CHAR_TO_BYTE8)
(CHAR_TO_BYTE_SAFE, CHAR_BYTE8_HEAD_P, CHARACTERP)
(CHECK_CHARACTER, CHECK_CHARACTER_CAR, CHECK_CHARACTER_CDR)
(CHAR_PRINTABLE_P, CHAR_BYTES, CHAR_LEADING_CODE, BYTE8_STRING)
(LEADING_CODE_P, TRAILING_CODE_P, CHAR_HEAD_P)
(BYTES_BY_CHAR_HEAD):
Now inline functions instead of macros.
(ASCII_CHAR_WIDTH): Remove; no longer used.
* src/conf_post.h (ATTRIBUTE_PURE): New macro.
* src/lisp.h (char_table_ref): Use it, for better inlining.
* src/fns.c (base64_decode_1): Add now-necessary casts.
Fix effect-free warning in ob-screen.el while loop
The warning was introduced and detected by an optimizer addition
proposed in the following thread:
https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00711.html
* lisp/org/ob-screen.el (org-babel-screen-test): Avoid 'value
returned from (format "...") is unused' warning by doing something
more useful than busy string manipulation while waiting for an
asynchronous subprocess to make the temporary file readable.