* lisp/calc/calc-graph.el (calc-gnuplot-check-for-errors):
* lisp/calendar/holidays.el (list-holidays):
Dodge 'save-excursion+set-buffer' warnings that appeared after
the progn flattening was introduced.
Propagate aliased lexical variables in byte compiler
Replace uses of a variable aliasing another variable with that aliased
variable, to allow for variable removal when possible. This also
enables opportunities for other optimisations. Example:
(let ((y x)) (f y)) => (f x)
The optimisation is only performed if both aliased and aliasing
variables are lexically bound. Shadowing bindings are α-renamed when
necessary for correctness. Example:
(let* ((b a) (a EXPR)) (f a b))
=> (let* ((a{new} EXPR)) (f a{new} a))
* lisp/emacs-lisp/byte-opt.el (byte-optimize--aliased-vars): New.
(byte-optimize-form-code-walker): Cancel aliasing upon mutation.
(byte-optimize--rename-var-body, byte-optimize--rename-var): New.
(byte-optimize-let-form): Add the optimisation.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add relevant test cases.
* lisp/net/tramp-sh.el (tramp-methods) <telnet, nc>: Don't use
"%n" marker.
* test/lisp/net/tramp-tests.el (tramp-test13-make-directory): Merge with
`tramp-test-make-directory-helper' and
`tramp-test13-make-directory-with-file-modes'.
(tramp-test44-asynchronous-requests): Use always the same
operation in timer.
Augusto Stoffel [Sat, 11 Sep 2021 13:02:04 +0000 (15:02 +0200)]
Allow using 'python-shell-send-file' across machines
* progmodes/python.el (python-shell-eval-file-setup-code): Look for a
file coding cookie on the Python rather than on the Emacs side, to
avoid additional file transfers.
(python-shell--save-temp-file): Allow argument to be a buffer.
(python-shell-send-file): Address the case where the selected file and
the inferior process are on different machines (bug#50516).
Augusto Stoffel [Sat, 11 Sep 2021 12:50:28 +0000 (14:50 +0200)]
Implement caching for 'python-shell-completion-at-point'
* lisp/progmodes/python.el (python-shell-completion-at-point): cache
results, since computing them involves talking with the inferior
process and, potentially, network communications
(python-shell--capf-cache): new variable, for cache
(python-shell-completion-get-completions)
(python-shell-completion-native-get-completions): 'import' argument is
not needed anymore.
(python-shell-completion-native-setup)
(python-shell-completion-native-try): pass the setup code
synchronously, to avoid printing a message in the shell (bug#50459).
Alan Third [Wed, 8 Sep 2021 16:57:50 +0000 (17:57 +0100)]
Fix display of tab-bar buttons
* src/xterm.c (x_draw_image_relief):
* src/w32term.c (w32_draw_image_relief): Fix the display of
tab-bar buttons when mouse pointer moves off the button.
(Bug#50424)
Eli Zaretskii [Sat, 11 Sep 2021 10:58:10 +0000 (13:58 +0300)]
Fix tab-bar scrolling for mice that report mouse-wheel events
* src/keyboard.c (make_lispy_position): Call
'window_from_coordinates' with last 2 arguments non-zero, to have
it report on tool-bar and tab-bar positions. Tweak the return
value according to the expectations of 'make_lispy_event'.
(make_lispy_event): No more need to inject "tab-bar" into a click
event on the tab bar: it's already there.
bug-reference-bug-regexp now defines a contract for the overlay region
Formerly, bug-reference-fontify placed the overlay on the complete
match of bug-reference-bug-regexp. That made it impossible to encode
constraints like "must not match at BOL" in the regexp without messing
up fontification. Therefore, now it establishes the contract that
subexpression 1 defines the overlay region. Subexpression 2 must
still match the part of the bug reference injected into
bug-reference-url-format if that's a string. If its a function, the
interpretation of subexpressions > 1 is up to the function.
For backwards compatibility, bug-reference-fontify checks if the
bounds of subexpression 2..10 are within the bounds of subexpession
1. If not, or subexpression 1 doesn't even exist/match, we fall back
to placing the overlay from (match-beginning 0) to (match-end 0) but
issue a warning.
* lisp/progmodes/bug-reference.el (bug-reference-bug-regexp): Document
contract that subexpression 1 defines the overlay region and adapt the
default value accordingly.
(bug-reference--nonconforming-regexps): New internal variable.
(bug-reference--overlay-bounds): New function.
(bug-reference-fontify): Place overlay on subexpression 1's bounds if
bug-reference-bug-regexp conforms to the documented contract.
(bug-reference--setup-from-vc-alist): Adapt regexps to new contract.
* doc/emacs/maintaining.texi (Bug Reference): Adapt regexp used in
example.
Eli Zaretskii [Sat, 11 Sep 2021 06:56:27 +0000 (09:56 +0300)]
Fix restoring from pdumper file on MS-Windows 9X
* src/pdumper.c (dump_map_file_w32): Use PAGE_WRITECOPY flag when
calling CreateFileMapping for DUMP_MEMORY_ACCESS_READWRITE access,
as that is required by Windows 9X. (Bug#50453)
* lisp/paren.el (show-paren--delete-overlays):
New function, extracted from show-paren-mode.
(show-paren-local-mode): New minor mode.
(show-paren-mode): Update docstring to mention it (bug#29381).
* lisp/progmodes/bug-reference.el (bug-reference--overlays-in): New
function.
(bug-reference-unfontify): Use it.
(bug-reference-fontify): Reuse and move existing overlays instead of
deleting all and creating them anew.
Arthur Miller [Fri, 10 Sep 2021 18:57:19 +0000 (20:57 +0200)]
Add support for GCC compiler command-line options
* lisp/emacs-lisp/comp.el ('native-comp-compiler-options): New option.
* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Add support
for new 'native-comp-compiler-options'.
* src/comp.c (Fcomp_native_compiler_options_effective_p): New function.
(add_compiler_options): New function.
(Fcomp__compile_ctxt_to_file): Call 'add_compiler_options'.
* lisp/progmodes/python.el (python-eldoc-at-point): Revert usage
of format-prompt in python.el since this is also an ELPA package
(and older Emacs versions doesn't have format-prompt).
Stephen Gildea [Fri, 10 Sep 2021 13:30:06 +0000 (06:30 -0700)]
Tramp: honor default file modes in make-directory
* lisp/net/tramp-sh.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-sudoedit.el:
* lisp/net/tramp-gvfs.el: Add support for default file modes to
relevant Tramp back ends for make-directory. (Closes: Bug#50410)
* test/lisp/net/tramp-tests.el (tramp-test13-make-directory-with-file-modes):
New test.
* etc/NEWS: Note this enhancement.
Thanks to Michael Albinus for helping improve this patch.
Eli Zaretskii [Fri, 10 Sep 2021 12:02:41 +0000 (15:02 +0300)]
Doc string followup to last change.
* lisp/progmodes/xref.el (xref-find-apropos): Mention
'tags-apropos-additional-actions' in the doc string.
* lisp/progmodes/etags.el (tags-apropos-additional-actions):
Mention 'xref-find-apropos' in the doc string.
Eli Zaretskii [Fri, 10 Sep 2021 11:57:38 +0000 (14:57 +0300)]
Document 'tags-apropos-additional-actions' with Xref
* doc/emacs/maintaining.texi (Looking Up Identifiers): Rearrange
and reword documentation of 'xref-find-apropos' and
'xref-auto-jump-to-first-definition'. Add the description of
'tags-apropos-additional-actions'. Delete the comment with
not-yet implemented features that were available with
'tags-apropos'.
* etc/NEWS: Augment the wording of 'xref-find-apropos' entry.
* lisp/isearch.el (isearch-beginning-of-buffer)
(isearch-end-of-buffer): Fix their behavior when
isearch-repeat-on-direction-change is non-nil (bug#50466).
Change the default value of search-whitespace-regexp
* lisp/isearch.el (search-whitespace-regexp): Change the default
to always exclude newlines from the set (bug#21278). It used to
be mode-dependent whether newlines were included or not, and this
was confusing as a user interface.
Support tags-apropos-additional-actions in etags Xref backend
* lisp/progmodes/etags.el (xref-etags-apropos-location):
New class.
(xref-location-marker): New method definition.
(xref-make-etags-apropos-location): New function.
(etags--xref-apropos-additional): New function.
(xref-backend-apropos): Use it here.
Eli Zaretskii [Thu, 9 Sep 2021 17:08:56 +0000 (20:08 +0300)]
Fix a recent change wrt 'comint-max-line-length'
* lisp/progmodes/python.el (python-shell-send-string): Only heed
'comint-max-line-length' for subprocesses with which we
communicate via PTYs. (Bug#49822)
* lisp/comint.el (comint-max-line-length): Doc fix. Add a value
for MS-Windows.
Augusto Stoffel [Thu, 9 Sep 2021 13:48:37 +0000 (15:48 +0200)]
Better treatment of line length limits for the Python inferior
* lisp/comint.el (comint-max-line-length): New constant reflecting a
safe maximum line size that can be sent to an inferior process.
* lisp/progmodes/python.el
(python-shell-comint-watch-for-first-prompt-output-filter): Send setup
code to the inferior process only once and at this stage.
(python-shell-eval-setup-code, python-shell-eval-file-setup-code):
Move, unchanged, to an earlier point to avoid byte-compiler warnings.
(python-shell-send-string-no-output): Revert changes of e32c7d2a8d
(python-shell-send-string): Use 'comint-max-line-length' to decide
when to resort to temp files.
(python-shell-send-string, python-shell-send-file): Don't send setup
code each time (bug#49822).
* lisp/simple.el (pop-mark): Don't ding at the user if there's no
mark to pop (bug#44375). This function is used (in some
circumstances) when the user mouse-1-clicks links (in *Help*
buffer, for instance), which will then ding at the user before
following the link.
* lisp/progmodes/python.el
(python-shell-completion-native-disabled-interpreters): Remove
ipython from list, because it apparently works fine these days
(bug#50458).
Don't output "probably introduced" if we know the answer for sure
* lisp/help-fns.el (help-fns--customize-variable-version):
Factored out from `help-fns--customize-variable' to be able to see
whether it outputs anything.
(help-fns--run-describe-functions): New function.
(help-fns--activated-functions): New internal variable.
(describe-variable): Use new function.
(describe-face, describe-function-1): Ditto (bug#50463).
Harald Jörg [Tue, 7 Sep 2021 20:11:41 +0000 (22:11 +0200)]
cperl-mode.el: Use rx sequences for Perl grammar
Following advice by Mattias Engdegård, most uses of rx-to-string
were eliminated, and rx sequences used instead to define Perl
grammar components.
* lisp/progmodes/cperl-mode.el: (cperl-block-declaration-p): New
function, replaces regexp literals.
(cperl-imenu--function-name-regexp-perl): Deleted, use rx
sequences to find imenu entries instead.
(cperl-indent-line): Use rx components instead of regexp literals.
(cperl-sniff-for-indent): use `cperl-block-declaration-p' to
increase accuracy, use rx sequence for labels to replace
inaccurate regexp literals.
(cperl-block-p): Replace inline comment by docstring. Use
`cperl-block-declaration-p'.
(cperl-after-block-p): Use `cperl-block-declaration-p'.
(cperl-after-block-and-statement-beg): Replace inline comment by
docstring.
(cperl-imenu-package-keywords), (cperl-imenu-sub-keywords),
(cperl-imenu-pod-keywords) : New variables to sort imenu
entries into categories.
(cperl-imenu--create-perl-index): Use rx sequences to collect
imenu entries.
(cperl-init-faces): Use rx components instead of regexp literals
for labels.
* test/lisp/progmodes/cperl-mode-tests.el: Test rx sequences
instead of regexp strings
Eric Abrahamsen [Tue, 7 Sep 2021 18:51:39 +0000 (11:51 -0700)]
Don't let nndiary.el alter variables when loading file
* lisp/gnus/nndiary.el (nndiary-open-server): Move the manipulation of
`gnus-extra-headers' and `nnmail-extra-headers' into this function: it
should only happen if we're actually firing up an nndiary server.
Previously, simply attempting to complete a gnus-* prefixed symbol
could end up loading this file, and changing the variable values.
* lisp/net/browse-url.el (browse-url-default-windows-browser)
(browse-url-default-macosx-browser): Encode the URL before using
(in case it contains spaces) (bug#50435).
* lisp/net/browse-url.el (browse-url-url-encode-chars): Document
what the argument really is, and simplify the implementation
(bug#50435).
(browse-url-encode-url): Encode spaces.
Eli Zaretskii [Tue, 7 Sep 2021 13:03:27 +0000 (16:03 +0300)]
Improve documentation of new Xref options
* lisp/progmodes/xref.el (xref-auto-jump-to-first-definition)
(xref-auto-jump-to-first-xref): More accurate description in the
doc strings.
* doc/emacs/maintaining.texi (Looking Up Identifiers)
(Identifier Search, List Identifiers, Project File Commands): Fix
the documentation of 'xref-auto-jump-to-first-definition' and
'xref-auto-jump-to-first-xref' to be more accurate.
* etc/NEWS: More accurate wording of the entry about
'xref-auto-jump-to-first-definition' and
'xref-auto-jump-to-first-xref'.
Michael Albinus [Tue, 7 Sep 2021 12:36:06 +0000 (14:36 +0200)]
Do not expand default method, user, host in remote file name completion
* lisp/net/tramp.el (tramp-completion-handle-file-name-all-completions):
Do not expand default method, user, host. (Bug#50387)
(tramp-get-completion-methods): `partial-method' can be nil.
Support specifying just one command in project-switch-commands
* lisp/progmodes/project.el (project-switch-commands):
Describe the new possible type of value.
(project--switch-project-command):
New function, extract from project-switch-project.
(project-switch-project): If project-switch-commands's value is a
symbol, invoke that command without showing a menu.
Add possibility to override the default highlighting
* lisp/progmodes/bug-reference.el (bug-reference-fontify): Highlight
99th group if it exists.
(bug-reference-bug-regexp): Document that regexp group 99 can be used
to override the default behavior of highlighting the complete match.
(bug-reference--run-auto-setup): Use run-hook-with-args-until-success
instead of throw/catch.
Normalise nested `progn` forms in byte-code optimiser
* lisp/emacs-lisp/byte-opt.el (byte-optimize-body): Flatten body.
This simplifies the source tree and reduces the number of different
cases that other optimisations need to take into account.
Treat `ignore` as any other function during source-level optimisation,
to avoid having its warning-suppression effects cancelled by repeated
passes. Instead, define a custom code generation function.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Don't treat `ignore' specially here.
(side-effect-free-fns): Don't mark `ignore` as side-effect-free
or error-free (although it is), since that would allow the optimiser
to elide calls.
* lisp/emacs-lisp/bytecomp.el (ignore, byte-compile-ignore):
Define and register a code-gen function.
Optimise `member` and `assoc` (etc) with constant empty list
* lisp/emacs-lisp/byte-opt.el
(byte-optimize-assq): New.
(byte-optimize-member, byte-optimize-assoc, byte-optimize-memq):
When the list argument is constant nil, the result is always nil.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test cases.
* lisp/dired-aux.el (dired-do-find-regexp-and-replace):
Disregard the customized value of xref-auto-jump-to-first-xref
(it breaks the xref-query-replace-in-results invocation).
* lisp/progmodes/xref.el (xref-auto-jump-to-first-xref):
Mention the caveat for users or xref distributed through ELPA.