Harald Jörg [Tue, 16 Feb 2021 23:54:38 +0000 (00:54 +0100)]
cperl-mode: Improve detection of index entries for imenu
* lisp/progmodes/cperl-mode.el
(cperl-imenu-addback): Customization variable deleted. This
variable has been declared obsolete in 1998.
(cperl--basic-identifier-regexp) and many other variables:
defining regular expressions for basic Perl constructs.
(cperl-imenu--create-perl-index): This function has been
completely rewritten, keeping only some parts of the output
formatting. It now recognizes a lot more package and
subroutine declarations which came since Perl 5.14: Packages
with a version and/or a block attached, lexical subroutines,
declarations with a newline between the keyword "package" and
the package name, and several more. This version also
correctly separates subroutine names from attributes, does no
longer support "unnamed" packages (which don't exist in Perl),
and doesn't fall for false positives like stuff that looks
like a declaration in a multiline string.
(cperl-tags-hier-init): Eliminate call to
`cperl-imenu-addback` (which actually was commented out in
1997)
* test/lisp/progmodes/cperl-mode-tests.el
(cperl-test--validate-regexp) and six other new tests for the
new regular expressions and the index creation.
* test/lisp/progmodes/cperl-mode-resources/grammar.pl: New
file showcasing different syntax variations for package and
sub declarations (bug#46574).
Pacify unused function warning in xfns.c with GTK2
* src/xfns.c (x_get_net_workarea, x_get_monitor_for_frame)
(x_make_monitor_attribute_list, x_get_monitor_attributes_fallback):
[HAVE_XINERAMA] (x_get_monitor_attributes_xinerama)
[HAVE_XRANDR] (x_get_monitor_attributes_xrandr)
(x_get_monitor_attributes): Fix #ifdefs around definitions to avoid
unused function warnings regardless of GTK use (bug#46509).
[HAVE_XRANDR] (x_get_monitor_attributes_xrandr): Undefine
RANDR13_LIBRARY after it's been used.
* lisp/image-mode.el (image-mode): Switch disable-point-adjustment
on, otherwise `C-c C-c' will move point around oddly.
(image-toggle-display): Ensure that point is on the image (bug#46552).
* lisp/vc/smerge-mode.el:
(smerge-vc-next-conflict): While searching for conflict markers,
wrap search around if current file is the last one with conflicts
(bug#46538).
Stefan Monnier [Tue, 16 Feb 2021 04:54:45 +0000 (23:54 -0500)]
* lisp/emacs-lisp/bindat.el: Add 64bit int support
(bindat--unpack-u64, bindat--unpack-u64r, bindat--pack-u64)
(bindat--pack-u64r): New functions.
(bindat--unpack-item, bindat--pack-item): Use them.
(bindat--fixed-length-alist): Add new types.
Stefan Monnier [Tue, 16 Feb 2021 04:22:09 +0000 (23:22 -0500)]
* lisp/emacs-lisp/bindat.el: Clarify when field labels are optional
The fixes the doc and the Edebug spec, as well as a subtle issue in
the code where a field whose name is (eval 'fill) was mistakenly
considered as an anonymous field of type `fill`.
(bindat--unpack-item, bindat--unpack-group, bindat--length-group)
(bindat--pack-item, bindat--pack-group): Use dotimes, dolist, and pcase.
(bindat--item-aux): New edebug elem.
(bindat-item): Use it to fix the handling of optional fields.
(bindat-format-vector): Use `mapconcat`.
Stefan Monnier [Tue, 16 Feb 2021 02:25:15 +0000 (21:25 -0500)]
* lisp/emacs-lisp/bindat.el (bindat-spec): New macro.
It's basically an alias for `quote`, but it offers the advantage of
providing Edebug support and opens the possibility of compiling
the bindat spec to ELisp code.
* doc/lispref/processes.texi (Bindat Spec): Document `bindat-spec`.
(Bindat Functions): Tweak a few things to adjust to the state of the code.
* test/lisp/emacs-lisp/bindat-tests.el: Use it.
* test/lisp/emacs-lisp/edebug-tests.el (edebug-tests--read): New function.
(edebug-tests--&rest-behavior): New test.
Ulf Jasper [Mon, 15 Feb 2021 16:27:45 +0000 (17:27 +0100)]
Display yearly ical events from first year on. Fix Bug#23100.
Convert yearly rrule starting in year x into diary-anniversary entry
for year x-1 when importing an icalendar. Correspondingly convert
diary-anniversary for year x into yearly rrule starting in year x+1.
*
test/lisp/calendar/icalendar-resources/import-rrule-anniversary.diary-american:
*
test/lisp/calendar/icalendar-resources/import-rrule-anniversary.diary-european:
*
test/lisp/calendar/icalendar-resources/import-rrule-anniversary.diary-iso:
*
test/lisp/calendar/icalendar-resources/import-rrule-yearly.diary-american:
*
test/lisp/calendar/icalendar-resources/import-rrule-yearly.diary-european:
*
test/lisp/calendar/icalendar-resources/import-rrule-yearly.diary-iso:
*
test/lisp/calendar/icalendar-tests.el (icalendar-convert-anniversary-to-ical):
Match new diary-anniversary/yearly-rrule behaviour.
* lisp/calendar/icalendar.el (icalendar--datestring-to-isodate): Add
year-shift option. (icalendar--convert-anniversary-to-ical): Shift
the year as diary-anniversary is not displayed in the initial year.
(icalendar--convert-recurring-to-diary): Shift the year as
diary-anniversary is not displayed in the initial year. (Bug#23100)
* lisp/simple.el (completion-default-include-p): Rename and move
the checking for an explicit predicate down here...
(read-extended-command): ... from here.
(read-extended-command-predicate): Adjust default value.
* doc/lispref/modes.texi (Minor Modes): Document it.
* lisp/simple.el (global-minor-modes): New variable.
(completion-in-mode-p): Use it.
(completion-with-modes-p): Use it.
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Support it.
Stefan Monnier [Mon, 15 Feb 2021 02:13:35 +0000 (21:13 -0500)]
* Edebug: Generalize `&lookup`, use it for `cl-macrolet` and `cl-generic`
This allows the use of (declare (debug ...)) in the lexical macros
defined with `cl-macrolet`. It also fixes the names used by Edebug
for the methods of `cl-generic` so it doesn't need to use gensym
and so they don't include the formal arg names any more.
* lisp/emacs-lisp/edebug.el (edebug--match-&-spec-op):
Rename from `edebug--handle-&-spec-op`.
(edebug--match-&-spec-op <&interpose>): Rename from `&lookup` and
generalize so it can let-bind dynamic variables around the rest of the parse.
(edebug-lexical-macro-ctx): Rename from `edebug--cl-macrolet-defs` and
make it into an alist.
(edebug-list-form-args): Use the specs from `edebug-lexical-macro-ctx`
when available.
(edebug--current-cl-macrolet-defs): Delete var.
(edebug-match-cl-macrolet-expr, edebug-match-cl-macrolet-name)
(edebug-match-cl-macrolet-body): Delete functions.
(def-declarations): Use new `&interpose`.
(edebug--match-declare-arg): Rename from `edebug--get-declare-spec` and
adjust to new calling convention.
* lisp/subr.el (def-edebug-elem-spec): Fix docstring.
(eval-after-load): Use `declare`.
* lisp/emacs-lisp/cl-generic.el: Fix Edebug names so we don't need
gensym any more and we only include the specializers but not the formal
arg names.
(cl--generic-edebug-name): New var.
(cl--generic-edebug-remember-name, cl--generic-edebug-make-name): New funs.
(cl-defgeneric, cl-defmethod): Use them.
* lisp/emacs-lisp/cl-macs.el: Add support for `debug` declarations in
`cl-macrolet`.
(cl-declarations-or-string):
Fix use of `lambda-doc` and allow use of `declare`.
(edebug-lexical-macro-ctx): Declare var.
(cl--edebug-macrolet-interposer): New function.
(cl-macrolet): Use it to pass the right `lexical-macro-ctx` to the body.
* lisp/emacs-lisp/pcase.el (pcase-PAT): Use new `&interpose`.
(pcase--edebug-match-pat-args): Rename from `pcase--get-edebug-spec` and
adjust to new calling convention.
* test/lisp/emacs-lisp/cl-generic-tests.el (cl-defgeneric/edebug/method):
Adjust to the new names.
* test/lisp/emacs-lisp/edebug-tests.el (edebug-cl-defmethod-qualifier)
(edebug-tests-cl-flet): Adjust to the new names.
Stefan Kangas [Sun, 14 Feb 2021 23:43:15 +0000 (00:43 +0100)]
Avoid asking repeatedly about reloading bookmarks file
* lisp/bookmark.el (bookmark-maybe-load-default-file): Reload watched
bookmarks file only if its mtime has changed since the last query.
This avoids asking repeatedly about reloading the bookmarks file if
the user has already said "no" to a previous query.
(bookmark--watch-file-already-queried-p): New function.
(bookmark--watch-already-asked-mtime): New variable.
Bastian Beranek [Mon, 8 Feb 2021 17:12:33 +0000 (18:12 +0100)]
Fix showing and hiding of tab-bar on new frames (bug#46299)
* lisp/tab-bar.el (tab-bar--update-tab-bar-lines)
(tab-bar--tab-bar-lines-for-frame):
New functions to update value of tab-bar-lines in frames.
(tab-bar-mode, tab-bar-new-tab-to, tab-bar-close-tab)
(tab-bar-close-other-tab, tab-bar-show :set):
Use new function.
(tab-bar-select-tab-modifiers :set):
Work around visual glitch.
Revert the bit about command_modes in previous patch set
* src/data.c (Fcommand_modes): Remove the subr bit -- it's not
necessary since it can just use a predicate.
* src/lisp.h (GCALIGNED_STRUCT): Remove command_modes.
* doc/emacs/m-x.texi (M-x): Document it.
* doc/lispref/commands.texi (Interactive Call): Document it further.
* lisp/simple.el (read-extended-command-predicate): New user option.
(read-extended-command-predicate): Use it.
(completion-in-mode-p): New function (the default predicate).
Add new 'declare' forms for command completion predicates
* doc/lispref/functions.texi (Declare Form): Document the new
`completion' and `modes' declarations.
* lisp/simple.el (completion-with-modes-p): New helper functions.
* lisp/emacs-lisp/byte-run.el (byte-run--set-completion)
(byte-run--set-modes):
(defun-declarations-alist): New declarations for `completion' and
`modes'.
* lisp/emacs-lisp/autoload.el (make-autoload): Pick the list of
modes from `interactive' out of the functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-lambda): Allow for the
extended `interactive' form.
* src/callint.c (Finteractive): Document the extended form.
* src/data.c (Finteractive_form): Return the interactive form in
the old format (even when there's an extended `interactive') to
avoid having other parts of Emacs be aware of this.
(Fcommand_modes): New defun.
* src/emacs-module.c (GCALIGNED_STRUCT): Allow for modules to
return command modes.
* src/lisp.h: New function module_function_command_modes.
Alan Third [Sun, 31 Jan 2021 20:19:53 +0000 (20:19 +0000)]
Fix flicker when resizing NS frame programmatically (bug#46155)
; Incidentally fixes bug#21326.
* src/nsterm.m ([EmacsView viewWillDraw]): New function.
([EmacsView viewDidResize:]): We now have to mark the frame for
display on resize.
([EmacsView initFrameFromEmacs:]): Retain frame contents on resize.
([EmacsView updateLayer]): Don't update the layer if the frame is
still garbaged.
Alan Third [Wed, 10 Feb 2021 22:12:16 +0000 (22:12 +0000)]
Remove aliasing on SVG images under scaled NS frames
* src/image.c (FRAME_SCALE_FACTOR): New #define for getting frame
scale factor.
(image_set_transform):
(svg_load_image): Use FRAME_SCALE_FACTOR.
* src/nsterm.m (ns_frame_scale_factor): Get the scale factor for an NS
frame.
Stefan Monnier [Sat, 13 Feb 2021 21:21:53 +0000 (16:21 -0500)]
* lisp/emacs-lisp/edebug.el (edebug--handle-&-spec-op <&name>): New method
(edebug--concat-name): New function.
(edebug-match-name, edebug-match-cl-generic-method-qualifier)
(edebug-match-cl-generic-method-args): Delete functions.
* doc/lispref/edebug.texi (Specification List): Document it.
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Use `&name`.
(cl-generic--method-qualifier-p): New predicate.
(cl-defmethod): Use it and `&name`.
* lisp/emacs-lisp/cl-macs.el (cl-defun, cl-iter-defun, cl-flet):
* lisp/emacs-lisp/eieio-compat.el (defmethod):
* lisp/emacs-lisp/gv.el (gv-define-setter):
* lisp/emacs-lisp/ert.el (ert-deftest): Use `&name`.
* lisp/erc/erc-backend.el (define-erc-response-handler): Use `declare`
and `&name`.
Augusto Stoffel [Fri, 12 Feb 2021 18:29:54 +0000 (19:29 +0100)]
Small correction to `isearch-lazy-highlight-buffer-update'
The value of point is now read after a potential change of buffer.
* lisp/isearch.el (isearch-lazy-highlight-buffer-update): Move call
to `point' after `select-window'.
Stefan Monnier [Sat, 13 Feb 2021 15:41:45 +0000 (10:41 -0500)]
(backtrace-goto-source-functions): Make it a normal abnormal hook
* lisp/emacs-lisp/backtrace.el (backtrace-goto-source-functions):
Don't mark it as buffer-local any more.
(backtrace-goto-source): Use `run-hook-with-args-until-success`.
* lisp/emacs-lisp/edebug.el (edebug-pop-to-backtrace): Clarify that the
hook is only intended to be modified buffer-locally.
* lisp/gnus/gnus-msg.el (gnus-group-mail, gnus-group-news)
(gnus-summary-mail-other-window, gnus-summary-news-other-window):
Remove stale comments about let-binding gnus-newsgroup-name, as they
should have been addressed (bug#37871#38).
Eli Zaretskii [Sat, 13 Feb 2021 12:57:25 +0000 (14:57 +0200)]
Fix vertical cursor motion among many images
* src/xdisp.c (move_it_in_display_line_to): Consider it
MOVE_POS_MATCH_OR_ZV if we are just after an image, stretch, or
display string, and the position matches exactly. This is needed
when one image follows another at TO_CHARPOS. (Bug#46464)
Stefan Kangas [Fri, 12 Feb 2021 23:21:36 +0000 (00:21 +0100)]
Comment out mysterious code from cperl-mode.el
* lisp/progmodes/cperl-mode.el: Comment out mysterious code referring
to some unknown variable 'edit-var-mode-alist'. No one seems to know
what it is used for, so comment it out and see if anyone complains
before Emacs 28.1 or 28.2.
Stefan Kangas [Fri, 12 Feb 2021 23:10:38 +0000 (00:10 +0100)]
Remove outdated documentation from cperl-mode.el
* lisp/progmodes/cperl-mode.el (cperl-tips, cperl-problems)
(cperl-praise, cperl-speed, cperl-mode): Doc fixes; remove references
to very old versions of Emacs and other "Emaxen".
(cperl-problems-old-emaxen): Make obsolete and remove information on
Emacs 20.3 and older.
Stefan Monnier [Sat, 13 Feb 2021 00:28:25 +0000 (19:28 -0500)]
Edebug: Overload `edebug-form-spec` even less
The `edebug-form-spec` symbol property was used both to map forms's
head symbol to the corresponding spec, and to map spec element names
to their expansion.
This lead to name conflicts which break instrumentation of examples such as
(cl-flet ((gate (x) x)) (gate 4))
because of the Edebug spec element `gate`.
So introduce a new symbol property `edebug-elem-spec`.
* lisp/subr.el (def-edebug-elem-spec): New function.
* lisp/emacs-lisp/edebug.el (edebug--get-elem-spec): New function.
(edebug-match-symbol): Use it.
(Core Edebug elems): Put them on `edebug-elem-spec` instead of
`edebug-form-spec`.
(ELisp special forms): Set their `edebug-form-spec` via dolist.
(Other non-core Edebug elems): Use `def-edebug-elem-spec`.
(edebug-\`): Use `declare`.
* test/lisp/emacs-lisp/edebug-tests.el
(edebug-tests--conflicting-internal-names): New test.
* test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
(edebug-test-code-cl-flet1): New test case.
* doc/lispref/edebug.texi (Specification List): Add `def-edebug-elem-spec`.
(Specification Examples): Use it.
* doc/lispref/loading.texi (Hooks for Loading): Avoid the use of
`def-edebug-spec` in example (better use `debug` declaration).
Stefan Monnier [Fri, 12 Feb 2021 21:08:01 +0000 (16:08 -0500)]
Use `declare` instead of `def-edebug-spec` in most places
* lisp/speedbar.el: Use lexical-binding.
(speedbar-with-writable): Use `declare`.
* lisp/subr.el (def-edebug-spec): Use `declare`.
* lisp/cedet/ede/base.el: Use lexical-binding.
(ede-with-projectfile): Use `declare`.
(recentf-exclude): Declare var.
* lisp/cedet/ede/pmake.el: Use lexical-binding.
(ede-pmake-insert-variable-shared, ede-pmake-insert-variable-once):
Use `declare`.
* lisp/cedet/ede/proj-comp.el: Use lexical-binding.
(ede-compiler-begin-unique, ede-compiler-only-once)
(ede-linker-begin-unique, ede-linker-only-once): Use `declare`.
* lisp/cedet/semantic/ctxt.el: Use lexical-binding.
(semantic-with-buffer-narrowed-to-context)
(semantic-with-buffer-narrowed-to-command): Use `declare`.
(semantic--progress-reporter): Declare var.
(semantic-ctxt-end-of-symbol-default): Remove unused var `fieldsep`.
* lisp/cedet/semantic/lex-spp.el: Use lexical-binding.
(define-lex-spp-macro-declaration-analyzer)
(define-lex-spp-include-analyzer, semantic-lex-with-macro-used)
(define-lex-spp-macro-undeclaration-analyzer): Use `declare`.
(semantic-lex-spp-symbol-remove): Rename arg to avoid colliding with
dynamic variable `obarray`.
(semantic-lex-spp-symbol-pop): Remove unused var `oldvalue`.
(semantic-lex-spp-lex-text-string): Remove unused var `analyzer`.
* lisp/cedet/semantic/lex.el (define-lex)
(semantic-lex-unterminated-syntax-protection, define-lex-analyzer)
(define-lex-regex-analyzer, define-lex-block-analyzer)
(semantic-lex-catch-errors): Use `declare`.
* lisp/cedet/semantic/tag.el: Use lexical-binding.
(semantic-with-buffer-narrowed-to-current-tag)
(semantic-with-buffer-narrowed-to-tag): Use `declare`.
* lisp/cedet/semantic/wisent.el: Use lexical-binding.
(define-wisent-lexer): Use `declare`.
* lisp/emacs-lisp/cl-lib.el (cl-pushnew): The arg to :test can be any
form not just function form.
* lisp/org/ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Use `declare`.
* lisp/org/ob-core.el (org-babel-map-src-blocks): Use `declare`.
(org-babel-result-cond): Simplify edebug spec.
Avoid traversing dead `if` branches in bytecode optimiser
There is no point in traversing conditional branches that are
statically known never to be executed. This saves some optimisation
effort, but more importantly prevents variable assignments and
references in those branches from blocking effective constant
propagation.
Also attempt to traverse as much as possible in an unconditional
context, which enables constant-propagation through (linear)
assignments.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form):
Rewrite the (tail) recursion into an explicit loop. Normalise a
return value of (quote nil) to nil, for easier subsequent
optimisations.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't
traverse dead `if` branches. Use unconditional traversion context
when possible.
* lisp/net/tramp.el (tramp-debug-message): Change defsubst into defun.
Until now the byte-compiler hasn't been clever enough to inline this
function but this is about to change; the code expansion is
unnecessary and makes compiler improvements more difficult to gauge.
Stefan Kangas [Fri, 12 Feb 2021 17:38:58 +0000 (18:38 +0100)]
; Fix recent regexp-opt conversion in cperl-mode
* lisp/progmodes/cperl-mode.el (cperl-init-faces): Add missing
identifiers found by static analysis of recent change.
Thanks to Mattias Engdegård <mattiase@acm.org>.