Original problem report by N. Jackson in:
https://lists.gnu.org/r/emacs-devel/2020-03/msg00047.html
I found some other warnings when I used gcc, and fixed them
with this patch.
* lib-src/etags.c: Include verify.h.
(xnmalloc, xnrealloc): Tell the compiler that NITEMS is
nononnegative and ITEM_SIZE is positive.
* src/conf_post.h (__has_attribute_returns_nonnull)
(ATTRIBUTE_RETURNS_NONNULL): New macros.
* src/editfns.c (Fuser_full_name): Don’t assume Fuser_login_name
returns non-nil.
* src/intervals.c (rotate_right, rotate_left, update_interval):
* src/intervals.h (LENGTH, LEFT_TOTAL_LENGTH, RIGHT_TOTAL_LENGTH):
Use TOTAL_LENGTH0 or equivalent on intervals that might be null.
* src/intervals.h (TOTAL_LENGTH): Assume arg is nonnull.
(TOTAL_LENGTH0): New macro, with the old TOTAL_LENGTH meaning.
(make_interval, split_interval_right): Add ATTRIBUTE_RETURNS_NONNULL.
* src/pdumper.c (dump_check_dump_off): Now returns void, since
no caller uses the return value. Redo assert to pacify GCC.
(decode_emacs_reloc): Add a seemingly-random eassume to pacify GCC.
Ugly, and I suspect due to a bug in GCC.
Alan Third [Wed, 4 Mar 2020 20:51:40 +0000 (20:51 +0000)]
Fix more NS_DRAW_TO_BUFFER #ifdefs (bug#39883)
* src/nsterm.m (ns_update_end): Make sure the frame is updated after
drawing.
(ns_focus):
(ns_unfocus): Should be checking on NS_DRAW_TO_BUFFER rather than if
it's Cocoa or GNUstep.
Paul Eggert [Tue, 3 Mar 2020 18:17:34 +0000 (10:17 -0800)]
Time division speedups
* src/timefns.c (frac_to_double) [FASTER_TIMEFNS]: Prefer intmax_t
division or double division to mpz division if they also yield the
correctly rounded result.
Paul Eggert [Tue, 3 Mar 2020 18:17:34 +0000 (10:17 -0800)]
Fix rounding errors in time conversion
* src/timefns.c (frac_to_double): Pass FLT_RADIX to mpz_sizeinbase
instead of doing the radix calculation ourselves, not always
correctly. Fix off-by-one error in scale, which caused
double-rounding.
(decode_time_components): Use frac_to_double (via decode_ticks_hz)
to fix double-rounding error that can occur even though
intermediate results are long double.
* test/src/timefns-tests.el (float-time-precision):
Test the above fixes.
Eli Zaretskii [Tue, 3 Mar 2020 16:40:28 +0000 (18:40 +0200)]
Fix handling MS-Windows keyboard input above the BMP
* src/w32term.c (w32_read_socket): If we get a WM_UNICHAR message
with a surrogate codepoint, assemble the corresponding character
code above the BMP from its UTF-16 encoding, communicated in two
consecutive WM_UNICHAR messages.
Štěpán Němec [Sat, 29 Feb 2020 18:43:53 +0000 (19:43 +0100)]
Use help-fns-short-filename in other describe- commands
The commit
2015-01-16T22:52:15-05:00!monnier@iro.umontreal.ca 24b7f77581
(Improve handling of doc-strings and describe-function for cl-generic)
added 'help-fns-short-filename', which provides file name shortening
smarter than a simple 'file-name-nondirectory' call, but besides the
generic/eieio functions ('cl--generic-describe', 'cl--describe-class',
'eieio-help-constructor'), it is currently only used by
'describe-function' (via 'help-fns-function-description-header').
Make the other help commands use it, too.
(Other than the obvious consistency/maintenance argument, my immediate
motivation for this change is the possibility to customize the file
name abbreviation by advising the function.)
* lisp/help.el (describe-mode): Move to help-fns.el. The command was
already depending on 'find-lisp-object-file-name' defined there.
* lisp/help-fns.el (describe-variable) (describe-face) (describe-keymap)
(describe-mode): Use 'help-fns-short-filename'.
Alan Third [Mon, 2 Mar 2020 17:54:32 +0000 (17:54 +0000)]
Fix macOS/GNUstep compilation warnings
* src/nsfns.m (handlePanelKeys): Unused function.
* src/nsterm.m (ns_set_appearance):
([EmacsView initFrameFromEmacs:]): Use EmacsWindow type instead of
NSWindow.
(ns_clip_to_row): Unused function.
(ns_dumpglyphs_stretch): Remove unused variable.
(ns_term_init):
([EmacsWindow setAppearance]): Only compile on macOS.
(ns_mouse_position): Make sure f is initialised on GNUstep.
* src/emacs.c (main): Move allocation of autorelease pool to before
first use.
Robert Pluim [Fri, 24 Jan 2020 13:11:44 +0000 (14:11 +0100)]
Don't attempt to cache glyph metrics for FONT_INVALID_CODE
This was causing massive slowdown in redisplay when eg #xfe0f
(VARIATION SELECTOR-16) was present, as the cache ended up very large,
unused, and being recreated on every call to font_fill_lglyph_metrics
(Bug#39133).
* src/composite.c (fill_gstring_body): Hoist FONT_OBJECT_P check out
of loop. Calculate glyph code and check for FONT_INVALID_CODE before
calling font_fill_lglyph_metrics. Pass glyph code to it.
* src/font.c (font_fill_lglyph_metrics): Add code parameter, move
glyph code calculation up the call stack into fill_gstring_body.
Štěpán Němec [Thu, 29 Aug 2019 17:32:08 +0000 (19:32 +0200)]
whitespace: Turn long lines regexp into a function (bug#36837)
* lisp/whitespace.el (whitespace-color-on): Turn long lines regexp
into a function to ensure it uses current 'whitespace-line-column'
and 'fill-column' values. (Bug#36837)
(whitespace-lines-regexp): New function.
Perform 'regexp-opt' on nested 'or' forms, and after expansion of
user-defined and 'eval' forms. Characters are now turned into strings
for wider 'regexp-opt' scope. This preserves the longest-match
semantics for string in 'or' forms over composition.
* doc/lispref/searching.texi (Rx Constructs): Document.
* lisp/emacs-lisp/rx.el (rx--normalise-or-arg)
(rx--all-string-or-args): New.
(rx--translate-or): Normalise arguments first, and check for strings
in subforms.
(rx--expand-eval): Extracted from rx--translate-eval.
(rx--translate-eval): Call rx--expand-eval.
* test/lisp/emacs-lisp/rx-tests.el (rx-or, rx-def-in-or): Add tests.
* etc/NEWS: Announce.
Stefan Kangas [Sun, 1 Mar 2020 00:19:23 +0000 (01:19 +0100)]
Make 'load-dangerous-libraries' obsolete (Bug#37819)
When 'load-dangerous-libraries' was t, Emacs allowed loading .elc
files compiled by XEmacs. This patch removes the support for that use
case, and declares the variable obsolete.
* lisp/subr.el (load-dangerous-libraries): Declare obsolete.
* src/lread.c (Fload): Ignore its value, and thereby refuse to load
files byte compiled by XEmacs.
(syms_of_lread): Update doc string of 'bytecomp-version-regexp' to not
refer to it.
* doc/emacs/building.texi (Lisp Libraries): Remove its documentation.
Distinguish offsets between manual-vs-automatic scrolling
as integers-vs-floats instead of positive-vs-negative integers.
* lisp/tab-line.el (tab-line-format-template): Use 'numberp'
instead of 'integerp', and 'truncate' instead of 'abs'.
(tab-line-format): When the window-buffer was updated, set window-parameter
to float to enable auto-hscroll after it was disabled on manual scrolling.
(tab-line-auto-hscroll-buffer): New variable with internal buffer.
(tab-line-auto-hscroll): Erase in tab-line-auto-hscroll-buffer.
Use 'numberp' instead of 'integerp', 'truncate' instead of 'abs',
and 'float' instead of '-'.
(tab-line-hscroll): Use 'numberp' instead of 'integerp',
and 'truncate' instead of 'abs'.
Paul Eggert [Fri, 28 Feb 2020 07:16:44 +0000 (23:16 -0800)]
Port timestamp tests to odd timezones, (TICKS . HZ)
* test/src/timefns-tests.el:
(format-time-string-padding-minimal-deletes-unneeded-zeros)
(format-time-string-padding-minimal-retains-needed-zeros)
(format-time-string-padding-spaces)
(format-time-string-padding-zeros-adds-on-insignificant-side):
Don't assume local time can represent 2000-02-15 00:00:00,
as there might be a DST jump over midnight.
Work even when timestamps are of (TICKS . HZ) form.
Simplify by avoiding need to call time-add.
Stefan Monnier [Thu, 27 Feb 2020 03:47:32 +0000 (22:47 -0500)]
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-function): No nil value
(eldoc--supported-p): Move after the vars it uses. Simplify.
(eldoc-print-current-symbol-info): Revert to previous code which
assumed a non-nil value of eldoc-documentation-function.
Paul Eggert [Thu, 27 Feb 2020 01:10:21 +0000 (17:10 -0800)]
nnmail-cache-close should not use nofollow
nnmail-cache-close did not work when ~/.nnmail-cache was a symlink
to some other directory. Reported by Michael Albinus (Bug#39793).
* lisp/gnus/nnbabyl.el (nnbabyl-create-mbox):
* lisp/gnus/nndiary.el (nndiary-generate-nov-file):
* lisp/gnus/nnfolder.el (nnfolder-possibly-change-group):
* lisp/gnus/nnmbox.el (nnmbox-create-mbox):
* lisp/gnus/nnml.el (nnml-generate-nov-file):
Pass ‘excl’ to nnmail-write-region when creating a file, for safety.
* lisp/gnus/nnmail.el (nnmail-write-region):
Add optional MUSTBENEW arg, to stay consistent with write-region.
Past ‘nofollow’ to set-file-modes only when MUSTBENEW is ‘excl’.
Noam Postavsky [Wed, 26 Feb 2020 01:09:00 +0000 (20:09 -0500)]
Define libgnutls-version properly
* src/gnutls.c (syms_of_gnutls) <libgnutls-version>: Define with
DEFVAR_LISP and add docstring, so that this variable will accessible by
help facilities.
Ryan Olson [Sun, 23 Feb 2020 15:15:10 +0000 (08:15 -0700)]
Show friendly message after package install
* lisp/emacs-lisp/package.el (package-install): Once we know the
package has successfully been installed using the `package-install`
command, instead of relying on the compile "Done" message, give a
message that tells the user that the package has been
installed. (Bug#21857)
Mark Oteiza [Tue, 25 Feb 2020 22:53:04 +0000 (17:53 -0500)]
Expose ElDoc functions in a hook (Bug#28257)
* lisp/emacs-lisp/eldoc.el: Update commentary.
(eldoc--eval-expression-setup): Use new hook.
(eldoc--supported-p): Accomodate new hook.
(eldoc-documentation-functions): New hook.
(eldoc-documentation-default, eldoc-documentation-compose): New
functions.
(eldoc-documentation-function): Use 'eldoc-documentation-default' as new
default value. Update documentation and custom attributes.
(eldoc-print-current-symbol-info): Accomodate possible null value for
'eldoc-documentation-function'.
* etc/NEWS: Mention them.
* doc/emacs/programs.texi (Emacs Lisp Documentation Lookup): Mention
new hook and changes to 'eldoc-documentation-function'.
* lisp/hexl.el (hexl-mode, hexl-revert-buffer-function):
* lisp/ielm.el (inferior-emacs-lisp-mode):
* lisp/progmodes/cfengine.el (cfengine3-mode):
* lisp/progmodes/elisp-mode.el (emacs-lisp-mode):
* lisp/progmodes/octave.el (octave-mode):
* lisp/progmodes/python.el (python-mode): Use new hook.
Michael Albinus [Tue, 25 Feb 2020 12:25:57 +0000 (13:25 +0100)]
Finish implementation of {set-}file-modes FLAG arg in Tramp
* lisp/net/tramp-adb.el (tramp-adb-handle-file-local-copy): Do not use
'nofollow for temporary files. Use `tramp-compat-set-file-modes'.
(tramp-adb-handle-write-region): Do not use 'nofollow for
temporary files.
(tramp-adb-handle-set-file-modes): Implement FLAG.
* lisp/net/tramp-compat.el (tramp-compat-file-modes)
(tramp-compat-set-file-modes): New defaliases.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-modes):
Make explicit check (eq flag 'nofollow).
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-modes): Implement FLAG.
(tramp-do-copy-or-rename-file-directly)
(tramp-sh-handle-file-local-copy, tramp-sh-handle-write-region):
Do not use 'nofollow for temporary files.
(tramp-get-remote-chmod-h): New defun.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-modes):
Implement FLAG.
(tramp-sudoedit-handle-write-region): Use `tramp-compat-set-file-modes'.
* lisp/net/tramp.el (tramp-default-file-modes): Optional argument FLAG.
(tramp-handle-file-modes): Use `file-truename' instead of
`file-chase-links'. The latter function does not work for remote
file names.
(tramp-handle-write-region): Call `tramp-default-file-modes' with
'nofollow if needed. Do not use 'nofollow for temporary files.
* test/lisp/net/tramp-tests.el
(tramp--test-ignore-make-symbolic-link-error): Check also for
"Cannot chmod .* with nofollow flag" error.
(tramp-test20-file-modes): Extend test.
(tramp--test-emacs28-p): New defun.
Paul Eggert [Tue, 25 Feb 2020 01:55:00 +0000 (17:55 -0800)]
Update from Gnulib
This incorporates:
2020-02-24 getloadavg: don't use /usr/local when cross-compiling on AIX
2020-02-24 fcntl: add witness of gnulib override
* lib/fcntl.in.h, m4/getloadavg.m4: Copy from Gnulib.
Eli Zaretskii [Mon, 24 Feb 2020 16:16:51 +0000 (18:16 +0200)]
Adapt the MS-Windows build to 'nofollow' changes
* nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_fchmodat)
(OMIT_GNULIB_MODULE_lchmod): Set to true to omit building these
modules on MS-Windows.
* nt/mingw-cfg.site (ac_cv_func_fchmodat)
(gl_cv_func_fchmodat_works, ac_cv_func_lchmod): Disable tests on
MS-Windows.
* src/w32.c (chmod_worker, lchmod, fchmodat): New functions.
(sys_chmod): Move most of the code to chmod_worker.
* src/w32.h (fchmodat, lchmod): Add prototypes.
Paul Eggert [Mon, 24 Feb 2020 00:19:42 +0000 (16:19 -0800)]
Add 'nofollow' flag to set-file-modes etc.
This avoids some race conditions (Bug#39683). E.g., if some other
program changes a file to a symlink between the time Emacs creates
the file and the time it changes the file’s permissions, using the
new flag prevents Emacs from inadvertently changing the
permissions of a victim in some completely unrelated directory.
* admin/merge-gnulib (GNULIB_MODULES): Add fchmodat.
* doc/lispref/files.texi (Testing Accessibility, Changing Files):
* doc/lispref/os.texi (File Notifications):
* etc/NEWS:
Adjust documentation accordingly.
* lib/chmodat.c, lib/fchmodat.c, lib/lchmod.c, m4/fchmodat.m4:
* m4/lchmod.m4: New files, copied from Gnulib.
* lib/gnulib.mk.in: Regenerate.
* lisp/dired-aux.el (dired-do-chmod):
* lisp/doc-view.el (doc-view-make-safe-dir):
* lisp/emacs-lisp/autoload.el (autoload--save-buffer):
* lisp/emacs-lisp/bytecomp.el (byte-compile-file):
* lisp/eshell/em-pred.el (eshell-pred-file-mode):
* lisp/files.el (backup-buffer-copy, copy-directory):
* lisp/gnus/mail-source.el (mail-source-movemail):
* lisp/gnus/mm-decode.el (mm-display-external):
* lisp/gnus/nnmail.el (nnmail-write-region):
* lisp/net/tramp-adb.el (tramp-adb-handle-file-local-copy)
(tramp-adb-handle-write-region):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-directly):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-write-region):
* lisp/net/tramp.el (tramp-handle-write-region)
(tramp-make-tramp-temp-file):
* lisp/server.el (server-ensure-safe-dir):
* lisp/url/url-util.el (url-make-private-file):
When getting or setting file modes, avoid following symbolic links
when the file is not supposed to be a symbolic link.
* lisp/doc-view.el (doc-view-make-safe-dir):
Omit no-longer-needed separate symlink test.
* lisp/gnus/gnus-util.el (gnus-set-file-modes):
* lisp/net/tramp.el (tramp-handle-file-modes):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-modes):
* src/fileio.c (symlink_nofollow_flag): New function.
(Ffile_modes, Fset_file_modes):
Support an optional FLAG arg. All C callers changed.
* lisp/net/ange-ftp.el (ange-ftp-set-file-modes):
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-modes):
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-modes):
* lisp/net/tramp-smb.el (tramp-smb-handle-set-file-modes):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-modes):
Accept an optional FLAG arg that is currently ignored,
and add a FIXME comment for it.
* m4/gnulib-comp.m4: Regenerate.
Wilson Snyder [Sun, 23 Feb 2020 22:18:08 +0000 (17:18 -0500)]
Add `verilog-auto-inst-template-required'.
* lisp/progmodes/verilog-mode.el (verilog-auto-inst-template-required)
(verilog-auto-inst): Add `verilog-auto-inst-template-required' to only
insert AUTOINST ports inside an AUTO_TEMPLATE, msg3170. Reported by Ted
Huang, Brian Magnuson.
Alan Mackenzie [Sun, 23 Feb 2020 19:43:56 +0000 (19:43 +0000)]
CC Mode: Protect against consecutive calls to before-change-functions ...
without an intervening call to after-change-functions. This would have been a
workaround to bug #38691 had the causes of that bug not been removed.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): Add an extra value to
this variable, 'whole-buffer, this being set by c-before-change as a signal to
c-after-change that although c-before-change has run, it has assumed the
entire buffer as the change region.
(c-before-change, c-after-change): Adapt to the new meaning of the above.
Glenn Morris [Sun, 23 Feb 2020 15:50:33 +0000 (07:50 -0800)]
Merge from origin/emacs-27
ba7004b2a7 (origin/emacs-27) Shorten some ppss struct field names 693749c60f Java Mode: Fix fontification of variable decl inside `for' 884b68ca2c CC Mode: Fontify foo in "const auto foo :" correctly
Glenn Morris [Sun, 23 Feb 2020 15:50:28 +0000 (07:50 -0800)]
Merge from origin/emacs-27
dd5756436c Move more logic to vc-ignore from vc-default-ignore 2aed279be1 Warn about the likes of "[:alnum:]" in regexps 0273f261a7 Don't write absolute filenames and duplicate strings to CV... d7c22338d2 Fix cursor-sensor--detect when current buf != selected win... 2e39fc83bb * doc/emacs/sending.texi (Mail Sending): Fix index entries. b410f902d5 Document 'message-send-mail-function' in the Emacs manual ac0546612d Fix reference to 'message-send-and-exit' in Emacs manual cd6a9b8f65 Skip shell prompt on current line in Eshell even if it's p...
Alan Mackenzie [Sun, 23 Feb 2020 11:00:28 +0000 (11:00 +0000)]
CC Mode: Fontify foo in "const auto foo :" correctly
* lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): While attempting to
find a declaration's identifier, recast the latest found id. as that
identifier when there is no other type identifier and the result of the most
recent c-forward-type call is 'maybe or 'found. In the latter case, remove
the id. from the found types list, too.
Dmitry Gutov [Sat, 22 Feb 2020 23:51:38 +0000 (01:51 +0200)]
Move more logic to vc-ignore from vc-default-ignore
* lisp/vc/vc-dir.el (vc-dir-ignore):
Pass relative file names to vc-ignore.
* lisp/vc/vc.el (vc-ignore): Move the responsibility of
constructing the ignore pattern (right now, most often a relative
file name) using a file name received from the user, here.
(vc-default-ignore): ...from here (bug#37189, see discussion).
Also clarify the docstring.
Paul Eggert [Sat, 22 Feb 2020 16:04:16 +0000 (08:04 -0800)]
Restore runtime check for invalid tag
* src/data.c (wrong_type_argument): Restore check that the
object’s tag is valid, since invalid tags exist again.
* src/lisp.h (Lisp_Type_Unused0): New constant.
Eli Zaretskii [Sat, 22 Feb 2020 09:07:42 +0000 (11:07 +0200)]
Warn about the likes of "[:alnum:]" in regexps
* doc/lispref/searching.texi (Char Classes): Warn about erroneous
usage of named character classes. Suggested by Stephen Leake
<stephen_leake@stephe-leake.org>.
Wolfgang Scherer [Fri, 21 Feb 2020 20:28:11 +0000 (21:28 +0100)]
Don't write absolute filenames and duplicate strings to CVS ignore files
* lisp/vc/vc-cvs.el (vc-cvs-ignore): Expand filename correctly
and pass on only the basename as the pattern.
(vc-cvs-append-to-ignore) Do not write duplicate strings to
.cvsignore. New optional parameter SORT to more explicitly
control sorting of the ignore entries. (Bug#37215)
* lisp/vc/pcvs.el (cvs-mode-ignore): Call 'vc-cvs-append-to-ignore'
with SORT argument.
Federico Tedin [Mon, 17 Feb 2020 21:24:40 +0000 (22:24 +0100)]
Allow tempo-define-template to reassign tags to new templates
* lisp/tempo.el (tempo-define-template): Update documentation string
to mention that existing tags can be reassigned new templates.
(tempo-add-tag): Allow reassigning tags to new templates.
Additionally, invalidate tag collections in all buffers if the global
tags list is being modified.
(tempo-invalidate-collection): Allow invalidating tag collections in
all buffers at the same time.
* test/lisp/tempo-tests.el (tempo-define-tag-globally-test): Add a
test to check that new templates plus tags can be defined from any
buffer and then immediately used in other buffers.
(tempo-overwrite-tag-test): Add a test to check that tags can be
reassigned templates.
* etc/NEWS: Announce changes in tempo.el.