commit afc0aa3683568dc93469f636367f85e579ab2612 (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Thu Apr 11 09:53:34 2024 +0300 ; * lisp/minibuffer.el (completion-base-suffix): Doc fix (bug#48356). diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index ffa5dc10c78..3d0a6f9694f 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -112,15 +112,17 @@ the closest directory separators." (cons (or (cadr boundaries) 0) (or (cddr boundaries) (length suffix))))) -(defun completion-base-suffix (start end table predicate) - "Return the completion boundary suffix as substring. -START and END are the beginning and end of the entity being completed. -TABLE and PREDICATE are completion table and predicate." +(defun completion-base-suffix (start end collection predicate) + "Return suffix of completion of buffer text between START and END. +COLLECTION and PREDICATE are, respectively, the completion's +completion table and predicate, as in `completion-boundaries' (which see). +Value is a substring of buffer text between point and END. It is +the completion suffix that follows the completion boundary." (let ((suffix (buffer-substring (point) end))) (substring suffix (cdr (completion-boundaries (buffer-substring start (point)) - table + collection predicate suffix))))) commit 5d35ef858a9a949f682ef7b5fc6c0eae9f415936 Author: Eli Zaretskii Date: Thu Apr 11 08:55:12 2024 +0300 ; Fix whitespace in editfns-tests.el * test/src/editfns-tests.el (editfns-tests--before/after-change-functions): Fix whitespace. diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index a7fcef86209..a02bab73c09 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -520,7 +520,7 @@ (insert "ééé") (encode-coding-region beg (point) 'utf-8) (should (null (sanity-check-change-functions-errors)))) - + (sanity-check-change-functions-with-op 'DECODE-CODING-REGION (decode-coding-region beg (point) 'utf-8) (should (null (sanity-check-change-functions-errors))))) commit ad428e39d7380f091a487d58ee47e7b1c094b5f9 Author: Po Lu Date: Thu Apr 11 10:31:17 2024 +0800 Guarantee presence of emacs-module.h during cross-compilation * cross/Makefile.in (src/emacs-module.h): New rule. (src/libemacs.so): Depend on the same. diff --git a/cross/Makefile.in b/cross/Makefile.in index c1fe4e40b13..1e8daea6f91 100644 --- a/cross/Makefile.in +++ b/cross/Makefile.in @@ -146,13 +146,16 @@ src/Makefile: $(top_builddir)/src/Makefile.android src/epaths.h: $(top_builddir)/src/epaths.h $(AM_V_GEN) cp -f -p $< $@ +src/emacs-module.h: $(top_builddir)/src/emacs-module.h + $(AM_V_GEN) cp -f -p $< $@ + src/config.h: $(top_builddir)/src/config.h.android $(AM_V_GEN) cp -f -p $< $@ .PHONY: src/android-emacs src/libemacs.so -src/libemacs.so: src/Makefile src/config.h src/epaths.h src/verbose.mk \ - lib/libgnu.a $(PRE_BUILD_DEPS) +src/libemacs.so: src/Makefile src/config.h src/epaths.h \ + src/verbose.mk src/emacs-module.h lib/libgnu.a $(PRE_BUILD_DEPS) $(MAKE) -C src libemacs.so src/android-emacs: src/Makefile src/config.h lib/libgnu.a \ commit 3b6bc312f2383aaf275f1085621aaa593d18fc87 Author: Po Lu Date: Thu Apr 11 10:25:29 2024 +0800 Guarantee presence of epaths.h during cross-compilation * cross/Makefile.in (src/epaths.h): New rule. (src/libemacs.so): Depend on the same. diff --git a/cross/Makefile.in b/cross/Makefile.in index 6f2250fe02f..c1fe4e40b13 100644 --- a/cross/Makefile.in +++ b/cross/Makefile.in @@ -143,12 +143,15 @@ src/Makefile: $(top_builddir)/src/Makefile.android -e 's/-I\$$(top_srcdir)\/lib/-I..\/$(subst /,\/,$(srcdir))\/lib/g' \ < $(top_builddir)/src/Makefile.android > $@ +src/epaths.h: $(top_builddir)/src/epaths.h + $(AM_V_GEN) cp -f -p $< $@ + src/config.h: $(top_builddir)/src/config.h.android $(AM_V_GEN) cp -f -p $< $@ .PHONY: src/android-emacs src/libemacs.so -src/libemacs.so: src/Makefile src/config.h src/verbose.mk \ +src/libemacs.so: src/Makefile src/config.h src/epaths.h src/verbose.mk \ lib/libgnu.a $(PRE_BUILD_DEPS) $(MAKE) -C src libemacs.so commit b9acfd7c2b9d1fa5c49e7bd9f78a040f7485b29b Author: Po Lu Date: Thu Apr 11 10:15:25 2024 +0800 Optimize R8 configuration * java/org/gnu/emacs/EmacsWindowManager.java (WindowConsumer): Mark as package-local. * java/proguard.conf: List only symbols that must be preserved, enabling R8 to optimize the remainder. diff --git a/java/org/gnu/emacs/EmacsWindowManager.java b/java/org/gnu/emacs/EmacsWindowManager.java index 22629cad329..e41b4e068a7 100644 --- a/java/org/gnu/emacs/EmacsWindowManager.java +++ b/java/org/gnu/emacs/EmacsWindowManager.java @@ -84,7 +84,7 @@ public final class EmacsWindowManager MANAGER = new EmacsWindowManager (); }; - public interface WindowConsumer + interface WindowConsumer { public void attachWindow (EmacsWindow window); public EmacsWindow getAttachedWindow (); diff --git a/java/proguard.conf b/java/proguard.conf index 2fc974020ff..e6b08f76fe4 100644 --- a/java/proguard.conf +++ b/java/proguard.conf @@ -1,4 +1,4 @@ -# Trivial Proguard configuration file +# Proguard configuration files for Emacs # # Copyright (C) 2024 Free Software Foundation, Inc. # @@ -17,8 +17,37 @@ # You should have received a copy of the GNU General Public License # along with GNU Emacs. If not, see . # -# The effect of these two lines is to prevent the removal of symbol -# names, which Emacs requires to link to functions defined in Java. +# The effect of the following lines is to inhibit the removal of variable or +# method symbol names from symbols referenced from C. --keep,allowoptimization interface org.gnu.emacs.* --keep,allowoptimization class org.gnu.emacs.* { ; ; } +-keep,allowoptimization class org.gnu.emacs.EmacsClipboard { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsContextMenu { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsCursor { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsDesktopNotification { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsDialog { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsDirectoryEntry { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsFontDriver { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsFontDriver$* { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsGC { ; ; } +-keep,allowoptimization class org.gnu.emacs.EmacsHandleObject { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsPixmap { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsService { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsWindow { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsNative { ; } +-keep,allowoptimization class org.gnu.emacs.EmacsNoninteractive { ; } +-keep,allowoptimization interface org.gnu.emacs.EmacsDrawable { ; } + +# And these lines inhibit the deletion of symbols that are referenced by +# the operating system while enabling the compiler to minify or delete +# symbols only referenced internally. + +-keep,allowoptimization,allowaccessmodification public class * extends android.app.Activity +-keep,allowoptimization,allowaccessmodification public class * extends android.app.Application +-keep,allowoptimization,allowaccessmodification public class * extends android.app.Service +-keep,allowoptimization,allowaccessmodification public class * extends android.content.BroadcastReceiver +-keep,allowoptimization,allowaccessmodification public class * extends android.content.ContentProvider + +# Local Variables: +# truncate-lines: t +# indent-tabs-mode: nil +# End: commit 7720c614afcf2b657c1edd1901cdc688e372a53c Author: Po Lu Date: Thu Apr 11 09:11:44 2024 +0800 Adjust priority of Emacs background service notification * java/org/gnu/emacs/EmacsService.java (onStartCommand): Reword lightly and set importance to IMPORTANCE_LOW. diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 052793eabaf..b8ff98e79a7 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -182,11 +182,11 @@ public final class EmacsService extends Service manager = (NotificationManager) tem; infoBlurb = ("This notification is displayed to keep Emacs" + " running while it is in the background. You" - + " may disable it if you want;" + + " may disable it if you wish;" + " see (emacs)Android Environment."); channel = new NotificationChannel ("emacs", "Emacs Background Service", - NotificationManager.IMPORTANCE_DEFAULT); + NotificationManager.IMPORTANCE_LOW); manager.createNotificationChannel (channel); notification = (new Notification.Builder (this, "emacs") .setContentTitle ("Emacs") commit 2733329b46a4687ef9e3d260cb776391ded47f52 Author: Po Lu Date: Thu Apr 11 08:54:08 2024 +0800 ; * java/Makefile.in: Render config.status relative to builddir. diff --git a/java/Makefile.in b/java/Makefile.in index 186194fb6ac..7d732be8f91 100644 --- a/java/Makefile.in +++ b/java/Makefile.in @@ -277,10 +277,10 @@ emacs.apk-in: install_temp install_temp/assets/directory-tree \ $(AM_V_SILENT) rm -rf install_temp # Makefile itself. -.PRECIOUS: $(top_srcdir)/config.status Makefile -$(top_srcdir)/config.status: $(top_srcdir)/configure.ac $(top_srcdir)/m4/*.m4 +.PRECIOUS: $(top_builddir)/config.status Makefile +$(top_builddir)/config.status: $(top_srcdir)/configure.ac $(top_srcdir)/m4/*.m4 $(MAKE) -C $(dir $@) $(notdir $@) -Makefile: $(top_srcdir)/config.status $(top_srcdir)/java/Makefile.in +Makefile: $(top_builddir)/config.status $(top_srcdir)/java/Makefile.in $(MAKE) -C .. java/$@ # AndroidManifest.xml: commit 0288bc6c949e82f72790a60d067da31428ca433a Author: Dmitry Gutov Date: Thu Apr 11 03:57:09 2024 +0300 Generalize the file-name specific workaround in minibuffer-completion-help * lisp/minibuffer.el (completion-base-suffix): New function (bug#48356). (minibuffer-completion-help): Use it here. (minibuffer-completion-help): Cut off the double completion boundary when it occurs inside completion-list-insert-choice-function.. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 41b20174be1..ffa5dc10c78 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -112,6 +112,18 @@ the closest directory separators." (cons (or (cadr boundaries) 0) (or (cddr boundaries) (length suffix))))) +(defun completion-base-suffix (start end table predicate) + "Return the completion boundary suffix as substring. +START and END are the beginning and end of the entity being completed. +TABLE and PREDICATE are completion table and predicate." + (let ((suffix (buffer-substring (point) end))) + (substring + suffix + (cdr (completion-boundaries (buffer-substring start (point)) + table + predicate + suffix))))) + (defun completion-metadata (string table pred) "Return the metadata of elements to complete at the end of STRING. This metadata is an alist. Currently understood keys are: @@ -2586,16 +2598,9 @@ The candidate will still be chosen by `choose-completion' unless (minibuffer-completion-base (substring string 0 base-size)) (base-prefix (buffer-substring (minibuffer--completion-prompt-end) (+ start base-size))) - (base-suffix - (if (or (eq (alist-get 'category (cdr md)) 'file) - completion-in-region-mode-predicate) - (buffer-substring - (save-excursion - (if completion-in-region-mode-predicate - (point) - (or (search-forward "/" nil t) (point-max)))) - (point-max)) - "")) + (base-suffix (completion-base-suffix start end + minibuffer-completion-table + minibuffer-completion-predicate)) (all-md (completion--metadata (buffer-substring-no-properties start (point)) base-size md @@ -2697,7 +2702,11 @@ The candidate will still be chosen by `choose-completion' unless (delete-minibuffer-contents) (insert start choice) ;; Keep point after completion before suffix - (save-excursion (insert end))) + (save-excursion (insert + (completion--merge-suffix + choice + (1- (length choice)) + end)))) (unless (or (zerop (length prefix)) (equal prefix (buffer-substring-no-properties commit ca528f7c6ac9b907564298bc96663579d09f9434 Author: Arash Esbati Date: Wed Apr 10 23:05:39 2024 +0200 Suppress bogus messages in the echo area * lisp/textmodes/reftex-dcr.el (reftex-view-crossref-when-idle): Check if point inside a mandatory argument where the cite/ref key usually resides. For example, with \cite[45]{emacs:30} and point on 4, the following bogus message in the echo area is suppressed: "cite: no such database entry: \cite[45]". (bug#38258) Fix docstring. diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el index 2c5e5cb7ce6..c8ca054407c 100644 --- a/lisp/textmodes/reftex-dcr.el +++ b/lisp/textmodes/reftex-dcr.el @@ -241,9 +241,9 @@ With argument, actually select the window showing the cross reference." (reftex-view-crossref current-prefix-arg)) (defun reftex-view-crossref-when-idle () - ;; Display info about crossref at point in echo area or a window. - ;; This function was designed to work with an idle timer. - ;; We try to get out of here as quickly as possible if the call is useless. + "Display info about crossref at point in echo area or a window. +This function is designed to work with an idle timer and returns quickly +if the call is useless." (and reftex-mode ;; Make sure message area is free if we need it. (or (eq reftex-auto-view-crossref 'window) (not (current-message))) @@ -255,7 +255,15 @@ With argument, actually select the window showing the cross reference." (save-excursion (search-backward "\\" nil t) (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)")) - + ;; Also check if point is inside a mandatory argument where the + ;; cite/ref key usually resides: (bug#38258) + (save-excursion + (condition-case nil + (let ((forward-sexp-function nil)) + (up-list -1) + (= (following-char) ?\{)) + (error nil))) + ;; Finally, call `reftex-view-crossref': (condition-case nil (let ((current-prefix-arg nil)) (cond commit 3a91186ad3707c7e3754616f1c7a2735d40fc33d Author: Eshel Yaron Date: Wed Apr 10 21:55:38 2024 +0200 ; Remove obsolete 'mouse-wheel-up/down-event' bindings Following commit e720ba62193 'mouse-wheel-up-event' and 'mouse-wheel-down-event' are translated to 'wheel-up/down' events, so we only need to bind 'wheel-down/up' in 'completion-preview--mouse-map'. * lisp/completion-preview.el: Don't require 'mwheel'. (completion-preview--mouse-map): Remove bindings for 'mouse-wheel-up/down-event'. diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index a1e0abe2e14..0bdc13bb8a5 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -52,8 +52,6 @@ ;;; Code: -(require 'mwheel) - (defgroup completion-preview nil "In-buffer completion preview." :group 'completion) @@ -135,18 +133,8 @@ If this option is nil, these commands do not display any message." "" #'completion-preview-insert "C-" #'completion-at-point "" #'completion-at-point - ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events - ;; and vice versa!! "" #'completion-preview-prev-candidate - "" #'completion-preview-next-candidate - (key-description (with-suppressed-warnings - ((obsolete mouse-wheel-up-event)) - (vector mouse-wheel-up-event))) - #'completion-preview-next-candidate - (key-description (with-suppressed-warnings - ((obsolete mouse-wheel-down-event)) - (vector mouse-wheel-down-event))) - #'completion-preview-prev-candidate) + "" #'completion-preview-next-candidate) (defvar-local completion-preview--overlay nil) commit 103a2fdf18d99c872e4adb01a15a8300164acd66 Author: Juri Linkov Date: Wed Apr 10 21:07:21 2024 +0300 * doc/lispref/parsing.texi (Parsing Program Source): Fix menu. Add the new node "User-defined Things" to the menu. diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 4fa5fb3d7ee..49db6585e88 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -44,6 +44,7 @@ source files that mix multiple programming languages. * Retrieving Nodes:: Retrieving nodes from a syntax tree. * Accessing Node Information:: Accessing node information. * Pattern Matching:: Pattern matching with query patterns. +* User-defined Things:: User-defined ``Things'' and Navigation. * Multiple Languages:: Parse text written in multiple languages. * Tree-sitter Major Modes:: Develop major modes using tree-sitter. * Tree-sitter C API:: Compare the C API and the ELisp API. commit 3eb462405e541175df99974cc06395bf191d412a Author: Andrea Corallo Date: Wed Apr 10 18:45:47 2024 +0200 * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): Improve last change. diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 5a3b7b48cc4..b13c63a2a08 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -941,16 +941,27 @@ Non memoized version of `comp-cstr-intersection-no-mem'." (null (neg cstr)) (equal (typeset cstr) '(cons))))) -(define-inline comp-cstr-type-p (cstr type) +(defun comp-cstr-type-p (cstr type) "Return t if CSTR is certainly of type TYPE." - (if-let ((pred (get type 'cl-deftype-satisfies))) + (when (with-comp-cstr-accessors - (and (null (range cstr)) - (null (neg cstr)) - (and (or (null (typeset cstr)) - (equal (typeset cstr) `(,type))) - (cl-every pred (valset cstr))))) - (error "Unknown predicate for type %s" type))) + (cl-case type + (integer + (if (or (valset cstr) (neg cstr)) + nil + (or (equal (typeset cstr) '(integer)) + (and (range cstr) + (or (null (typeset cstr)) + (equal (typeset cstr) '(integer))))))) + (t + (if-let ((pred (get type 'cl-deftype-satisfies))) + (and (null (range cstr)) + (null (neg cstr)) + (and (or (null (typeset cstr)) + (equal (typeset cstr) `(,type))) + (cl-every pred (valset cstr)))) + (error "Unknown predicate for type %s" type))))) + t)) ;; Move to comp.el? (defsubst comp-cstr-cl-tag-p (cstr) commit ee03a73375796feea94bb066cff7d7de680cae32 Author: Andrea Corallo Date: Wed Apr 10 18:15:12 2024 +0200 * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): New function. diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 73d445eb3f4..5a3b7b48cc4 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -941,6 +941,17 @@ Non memoized version of `comp-cstr-intersection-no-mem'." (null (neg cstr)) (equal (typeset cstr) '(cons))))) +(define-inline comp-cstr-type-p (cstr type) + "Return t if CSTR is certainly of type TYPE." + (if-let ((pred (get type 'cl-deftype-satisfies))) + (with-comp-cstr-accessors + (and (null (range cstr)) + (null (neg cstr)) + (and (or (null (typeset cstr)) + (equal (typeset cstr) `(,type))) + (cl-every pred (valset cstr))))) + (error "Unknown predicate for type %s" type))) + ;; Move to comp.el? (defsubst comp-cstr-cl-tag-p (cstr) "Return non-nil if CSTR is a CL tag." commit d4d8575bf00bb722bbb913fa5aa5b68c6dbef4d3 Author: Andrea Corallo Date: Wed Apr 10 18:03:26 2024 +0200 * lisp/emacs-lisp/comp-cstr.el (comp-cstr-symbol-p): Simplify. diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 7452b8568de..73d445eb3f4 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -929,11 +929,9 @@ Non memoized version of `comp-cstr-intersection-no-mem'." (with-comp-cstr-accessors (and (null (range cstr)) (null (neg cstr)) - (or (and (null (valset cstr)) + (and (or (null (typeset cstr)) (equal (typeset cstr) '(symbol))) - (and (or (null (typeset cstr)) - (equal (typeset cstr) '(symbol))) - (cl-every #'symbolp (valset cstr))))))) + (cl-every #'symbolp (valset cstr)))))) (defsubst comp-cstr-cons-p (cstr) "Return t if CSTR is certainly a cons." commit 219b98916bc498bf15bbef6577af648834d4727d Author: Andrea Corallo Date: Wed Apr 10 17:35:08 2024 +0200 * lisp/emacs-lisp/comp-cstr.el (comp-cstr-fixnum-p): Fix. diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index d6cb887759f..7452b8568de 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -912,7 +912,9 @@ Non memoized version of `comp-cstr-intersection-no-mem'." (defun comp-cstr-fixnum-p (cstr) "Return t if CSTR is certainly a fixnum." (with-comp-cstr-accessors - (when (null (neg cstr)) + (when (and (null (neg cstr)) + (null (valset cstr)) + (null (typeset cstr))) (when-let (range (range cstr)) (let* ((low (caar range)) (high (cdar (last range)))) commit 36cb16556c60bf4e703764eefd4fb6668ccc37cc Author: Stefan Monnier Date: Wed Apr 10 12:15:26 2024 -0400 (en/decode_coding_object): Fix `after-change-functions` For `en/decode-coding-string/region`, `after-change-functions` were either not run at all, or run only after deleting the text but not after inserting it. * src/coding.c (decode_coding_object, encode_coding_object): Run the after-change-functions after inserting the result. * test/src/editfns-tests.el (sanity-check-change-functions-with-op): New macro. (sanity-check-change-functions-errors): New function. (editfns-tests--before/after-change-functions): Use them to add cases for `en/decode-coding-string/region`. diff --git a/src/coding.c b/src/coding.c index c51ceb95475..b21f2ecf00a 100644 --- a/src/coding.c +++ b/src/coding.c @@ -8109,7 +8109,7 @@ decode_coding_object (struct coding_system *coding, set_buffer_internal (XBUFFER (src_object)); if (from != GPT) move_gap_both (from, from_byte); - if (EQ (src_object, dst_object)) + if (BASE_EQ (src_object, dst_object)) { struct Lisp_Marker *tail; @@ -8121,8 +8121,9 @@ decode_coding_object (struct coding_system *coding, } saved_pt = PT, saved_pt_byte = PT_BYTE; TEMP_SET_PT_BOTH (from, from_byte); - current_buffer->text->inhibit_shrinking = 1; - del_range_both (from, from_byte, to, to_byte, 1); + current_buffer->text->inhibit_shrinking = true; + prepare_to_modify_buffer (from, to, NULL); + del_range_2 (from, from_byte, to, to_byte, false); coding->src_pos = -chars; coding->src_pos_byte = -bytes; } @@ -8148,6 +8149,13 @@ decode_coding_object (struct coding_system *coding, } else if (BUFFERP (dst_object)) { + if (!BASE_EQ (src_object, dst_object)) + { + struct buffer *current = current_buffer; + set_buffer_internal (XBUFFER (dst_object)); + prepare_to_modify_buffer (PT, PT, NULL); + set_buffer_internal (current); + } code_conversion_save (0, 0); coding->dst_object = dst_object; coding->dst_pos = BUF_PT (XBUFFER (dst_object)); @@ -8168,7 +8176,14 @@ decode_coding_object (struct coding_system *coding, decode_coding (coding); if (BUFFERP (coding->dst_object)) - set_buffer_internal (XBUFFER (coding->dst_object)); + { + set_buffer_internal (XBUFFER (coding->dst_object)); + signal_after_change (coding->dst_pos, + BASE_EQ (src_object, dst_object) ? to - from : 0, + coding->produced_char); + update_compositions (coding->dst_pos, + coding->dst_pos + coding->produced_char, CHECK_ALL); + } if (! NILP (CODING_ATTR_POST_READ (attrs))) { @@ -8373,7 +8388,12 @@ encode_coding_object (struct coding_system *coding, if (same_buffer) { saved_pt = PT, saved_pt_byte = PT_BYTE; - coding->src_object = del_range_1 (from, to, 1, 1); + /* Run 'prepare_to_modify_buffer' by hand because we don't want + to run the after-change hooks yet. */ + prepare_to_modify_buffer (from, to, &from); + coding->src_object = del_range_2 (from, CHAR_TO_BYTE (from), + to, CHAR_TO_BYTE (to), + true); coding->src_pos = 0; coding->src_pos_byte = 0; } @@ -8404,11 +8424,12 @@ encode_coding_object (struct coding_system *coding, { struct buffer *current = current_buffer; - set_buffer_temp (XBUFFER (dst_object)); + set_buffer_internal (XBUFFER (dst_object)); + prepare_to_modify_buffer (PT, PT, NULL); coding->dst_pos = PT; coding->dst_pos_byte = PT_BYTE; move_gap_both (coding->dst_pos, coding->dst_pos_byte); - set_buffer_temp (current); + set_buffer_internal (current); } coding->dst_multibyte = ! NILP (BVAR (XBUFFER (dst_object), enable_multibyte_characters)); @@ -8446,6 +8467,16 @@ encode_coding_object (struct coding_system *coding, xfree (coding->destination); } } + else if (BUFFERP (coding->dst_object)) + { + struct buffer *current = current_buffer; + set_buffer_internal (XBUFFER (dst_object)); + signal_after_change (coding->dst_pos, same_buffer ? to - from : 0, + coding->produced_char); + update_compositions (coding->dst_pos, + coding->dst_pos + coding->produced_char, CHECK_ALL); + set_buffer_internal (current); + } if (saved_pt >= 0) { @@ -9510,7 +9541,7 @@ not fully specified.) */) DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, 3, 4, "r\nzCoding system: ", - doc: /* Encode the current region using th specified coding system. + doc: /* Encode the current region using the specified coding system. Interactively, prompt for the coding system to encode the region, and replace the region with the bytes that are the result of the encoding. diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index a14a5f90b65..a7fcef86209 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -428,9 +428,17 @@ ;;; Try and catch `*-changes-functions' bugs! -(defvar sanity-check--verbose nil) +(defvar sanity-check-change-functions-verbose nil) +(defvar sanity-check-change-functions-op nil) +(defmacro sanity-check-change-functions-with-op (op &rest body) + (declare (debug t) (indent 1)) + `(let ((sanity-check-change-functions-op ,op)) + (sanity-check--message "%S..." sanity-check-change-functions-op) + ,@body + (sanity-check--message "%S...done" sanity-check-change-functions-op))) + (defun sanity-check--message (&rest args) - (if sanity-check--verbose (apply #'message args))) + (if sanity-check-change-functions-verbose (apply #'message args))) (defvar-local sanity-check-change-functions-beg 0) (defvar-local sanity-check-change-functions-end 0) @@ -488,6 +496,12 @@ (+ sanity-check-change-functions-buffer-size offset))) (sanity-check-change-functions-check-size)) +(defun sanity-check-change-functions-errors () + (sanity-check-change-functions-check-size) + (if sanity-check-change-functions-errors + (cons sanity-check-change-functions-op + sanity-check-change-functions-errors))) + (ert-deftest editfns-tests--before/after-change-functions () (with-temp-buffer (add-hook 'before-change-functions @@ -496,8 +510,28 @@ #'sanity-check-change-functions-after nil t) ;; Bug#65451 - (insert "utf-8-unix\n\nUTF") - (call-interactively 'dabbrev-expand) - (should (null sanity-check-change-functions-errors)))) + (sanity-check-change-functions-with-op 'DABBREV-EXPAND + (insert "utf-8-unix\n\nUTF") + (call-interactively 'dabbrev-expand) + (should (null (sanity-check-change-functions-errors)))) + + (let ((beg (point))) + (sanity-check-change-functions-with-op 'ENCODE-CODING-REGION + (insert "ééé") + (encode-coding-region beg (point) 'utf-8) + (should (null (sanity-check-change-functions-errors)))) + + (sanity-check-change-functions-with-op 'DECODE-CODING-REGION + (decode-coding-region beg (point) 'utf-8) + (should (null (sanity-check-change-functions-errors))))) + + (sanity-check-change-functions-with-op 'ENCODE-CODING-STRING + (encode-coding-string "ééé" 'utf-8 nil (current-buffer)) + (should (null (sanity-check-change-functions-errors)))) + + (sanity-check-change-functions-with-op 'DECODE-CODING-STRING + (decode-coding-string "\303\251\303\251\303\251" + 'utf-8 nil (current-buffer)) + (should (null (sanity-check-change-functions-errors)))))) ;;; editfns-tests.el ends here commit 15bafc04322e9c4e85a00fe593239935eb723b6e Author: Po Lu Date: Wed Apr 10 23:22:38 2024 +0800 * java/Makefile.in (classes.dex): Make proguard.conf relative to srcdir. diff --git a/java/Makefile.in b/java/Makefile.in index daa577467c1..186194fb6ac 100644 --- a/java/Makefile.in +++ b/java/Makefile.in @@ -305,14 +305,14 @@ $(CLASS_FILES) &: $(JAVA_FILES) # N.B. that find must be called all over again in case javac generated # nested classes. -classes.dex: $(CLASS_FILES) $(if $(IS_D8_R8), proguard.conf) +classes.dex: $(CLASS_FILES) $(if $(IS_D8_R8), $(srcdir)/proguard.conf) $(AM_V_D8) $(D8) --classpath $(ANDROID_JAR) \ $(subst $$,\$$,$(shell find $(srcdir) -type f \ -name *.class)) --output $(builddir) \ --min-api $(ANDROID_MIN_SDK) \ $(if $(filter false,$(ANDROID_DEBUGGABLE)),--release, \ --debug) \ - $(if $(IS_D8_R8),--pg-conf proguard.conf) + $(if $(IS_D8_R8),--pg-conf $(srcdir)/proguard.conf) # When emacs.keystore expires, regenerate it with: # commit 0bfc1d4e7eedb8496a293cf51c2b731a43c2010e Merge: 049bdfdaec4 33516970808 Author: Po Lu Date: Wed Apr 10 22:34:02 2024 +0800 Merge remote-tracking branch 'savannah/master' into master-android-1 commit 049bdfdaec4ee0c791fbf034b683e06ee84ce1db Author: Po Lu Date: Wed Apr 10 22:33:33 2024 +0800 * java/proguard.conf: New file. diff --git a/java/proguard.conf b/java/proguard.conf new file mode 100644 index 00000000000..2fc974020ff --- /dev/null +++ b/java/proguard.conf @@ -0,0 +1,24 @@ +# Trivial Proguard configuration file +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# This file is part of GNU Emacs. +# +# GNU Emacs is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see . +# +# The effect of these two lines is to prevent the removal of symbol +# names, which Emacs requires to link to functions defined in Java. + +-keep,allowoptimization interface org.gnu.emacs.* +-keep,allowoptimization class org.gnu.emacs.* { ; ; } commit ed88bed3afbc9922f020cf3a8803e08f2811e89b Author: Po Lu Date: Wed Apr 10 22:33:08 2024 +0800 Optimize generated Android DEX bytecode * configure.ac (D8): Attempt to locate the bundle where d8 is installed, detect whether an installation of `r8' is similarly present, and use this installation in place of d8 if so. * java/Makefile.in (ANDROID_MIN_SDK, IS_D8_R8): New substitutions. (classes.dex): Provide --min-api, --debug or --release and --pg-conf to d8 or r8. diff --git a/configure.ac b/configure.ac index b1dbaa13155..d3effc0f4f3 100644 --- a/configure.ac +++ b/configure.ac @@ -856,6 +856,7 @@ ANDROID_ABI= WARN_JAVAFLAGS= ANDROID_SHARED_USER_ID= ANDROID_SHARED_USER_NAME= +IS_D8_R8= # This is a list of Makefiles that have alternative versions for # Android. @@ -1023,6 +1024,21 @@ Please verify that the path to the SDK build tools you specified is correct]) Please verify that the path to the SDK build tools you specified is correct]) fi + # Locate any d8.jar within the SDK build tools directory. The R8 + # optimizing compiler is also present in this bundle, and it generates + # far superior code. + emacs_val=`which $D8` + emacs_val=`AS_DIRNAME([$emacs_val])`/lib/d8.jar + AS_IF([test -f "$emacs_val"], + [AC_CACHE_CHECK([whether d8.jar coresident with d8 binary provides r8], + [emacs_cv_d8_provides_r8], + [AS_IF([java -cp "$emacs_val" com.android.tools.r8.R8 --help &>/dev/null], + [emacs_cv_d8_provides_r8=yes], [emacs_cv_d8_provides_r8=no])])]) + AS_IF([test "$emacs_cv_d8_provides_r8" = "yes"], + # And substitute it for D8 if present. + [D8="java -cp $emacs_val com.android.tools.r8.R8" + IS_D8_R8=yes]) + AC_PATH_PROGS([ZIPALIGN], [zipalign], [], "${SDK_BUILD_TOOLS}:$PATH") if test "ZIPALIGN" = ""; then AC_MSG_ERROR([The Android ZIP archive alignment utility was not found. @@ -1281,6 +1297,7 @@ AC_SUBST([D8]) AC_SUBST([ZIPALIGN]) AC_SUBST([ANDROID_JAR]) AC_SUBST([ANDROID_ABI]) +AC_SUBST([IS_D8_R8]) if test "$XCONFIGURE" = "android"; then ANDROID=yes diff --git a/java/Makefile.in b/java/Makefile.in index c23b52ed44e..daa577467c1 100644 --- a/java/Makefile.in +++ b/java/Makefile.in @@ -98,6 +98,12 @@ JAVA_FILES := $(filter-out $(RESOURCE_FILE),$(JAVA_FILES)) ANDROID_MIN_SDK := @ANDROID_MIN_SDK@ APK_NAME := emacs-$(version)-$(ANDROID_MIN_SDK)-$(ANDROID_ABI).apk +# Whether or not the bundle is to be debuggable. +ANDROID_DEBUGGABLE := @ANDROID_DEBUGGABLE@ + +# Whether or not $(D8) is in fact the name of the `r8' optimizer binary. +IS_D8_R8 := @IS_D8_R8@ + # How this stuff works. # emacs.apk depends on emacs.apk-in, which is simply a ZIP archive @@ -299,10 +305,14 @@ $(CLASS_FILES) &: $(JAVA_FILES) # N.B. that find must be called all over again in case javac generated # nested classes. -classes.dex: $(CLASS_FILES) +classes.dex: $(CLASS_FILES) $(if $(IS_D8_R8), proguard.conf) $(AM_V_D8) $(D8) --classpath $(ANDROID_JAR) \ $(subst $$,\$$,$(shell find $(srcdir) -type f \ - -name *.class)) --output $(builddir) + -name *.class)) --output $(builddir) \ + --min-api $(ANDROID_MIN_SDK) \ + $(if $(filter false,$(ANDROID_DEBUGGABLE)),--release, \ + --debug) \ + $(if $(IS_D8_R8),--pg-conf proguard.conf) # When emacs.keystore expires, regenerate it with: # commit 33516970808a6c50709325edfc1af125c2b2c401 Author: Eli Zaretskii Date: Wed Apr 10 17:00:34 2024 +0300 Fix 'format-seconds' when all values are zero and %z is used * lisp/calendar/time-date.el (format-seconds): Fix all-zero time. * test/lisp/calendar/time-date-tests.el (test-format-seconds): Add two new tests. (Bug#70322) diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index e96e2e7e2db..eca80f1e8b6 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -344,8 +344,11 @@ right of \"%x\", trailing zero units are not output." string) (cond ((string-equal spec "z") - (setq chop-leading (and leading-zeropos - (min leading-zeropos (match-beginning 0))))) + (setq chop-leading + (if leading-zeropos + (min leading-zeropos (match-beginning 0)) + ;; The entire spec is zero, get past "%z" to last 0. + (+ 2 (match-beginning 0))))) ((string-equal spec "x") (setq chop-trailing t)) (t diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/time-date-tests.el index 01f9f8a5108..6512dd0bd07 100644 --- a/test/lisp/calendar/time-date-tests.el +++ b/test/lisp/calendar/time-date-tests.el @@ -100,7 +100,10 @@ (should (equal (format-seconds "%hh %z%x%mm %ss" (* 60 2)) "2m")) (should (equal (format-seconds "%hh %z%mm %ss" (* 60 2)) "2m 0s")) (should (equal (format-seconds "%hh %x%mm %ss" (* 60 2)) "0h 2m")) - (should (equal (format-seconds "%hh %x%mm %ss" 0) "0h 0m 0s"))) + (should (equal (format-seconds "%hh %x%mm %ss" 0) "0h 0m 0s")) + ;; Bug#70322 + (should (equal (format-seconds "%y %z%d %h %m %s %%" 9999999) "115 17 46 39 %")) + (should (equal (format-seconds "%Y, %D, %H, %M, %z%S" 0) "0 seconds"))) (ert-deftest test-ordinal () (should (equal (date-ordinal-to-time 2008 271) commit f4711811298b320ea6875e635a7346f3bc23a603 Author: Andrea Corallo Date: Wed Apr 10 15:27:46 2024 +0200 * lisp/emacs-lisp/cl-macs.el (cl-typep): Add docstring. diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index a84ef4a34b2..1350e474d6a 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -3479,6 +3479,7 @@ Of course, we really can't know that for sure, so it's just a heuristic." ;;;###autoload (define-inline cl-typep (val type) + "Return t if VAL is of type TYPE, nil otherwise." (inline-letevals (val) (pcase (inline-const-val type) ((and `(,name . ,args) (guard (get name 'cl-deftype-handler)))