commit b2eed2ae568b53ac910f4a3b8458eedf8d8c67ec (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Thu May 20 11:26:00 2021 +0300 Clean up the fix for unexec build on GNU/Linux * src/conf_post.h [HYBRID_MALLOC || DARWIN_OS && HAVE_UNEXEC]: Include here, before redirecting 'malloc' and friends to their hybrid_* and unexec_* equivalents. #undef malloc and friends before redefining. Provide prototypes for the replacements. Suggested by Paul Eggert . * src/gmalloc.c [HYBRID_MALLOC]: Remove declarations of 'malloc' and friends, as they are now redundant: we include in conf_post.h before redefining 'malloc' etc., and that provides prototypes from system headers. * configure.ac (HYBRID_MALLOC): Remove kludge to avoid replacement of 'free' by Gnulib. (Bug#36649) diff --git a/configure.ac b/configure.ac index d35ac6dbd3..d99e5395d3 100644 --- a/configure.ac +++ b/configure.ac @@ -2309,9 +2309,6 @@ elif test "$hybrid_malloc" = yes; then GNU_MALLOC_reason=" (only before dumping)" GMALLOC_OBJ=gmalloc.o VMLIMIT_OBJ= - # FIXME: This is to prevent Gnulib from redirecting 'free' to its - # replacement, instead of 'hybrid_free' in gmalloc.c. - gl_cv_func_free_preserves_errno=yes else test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o VMLIMIT_OBJ=vm-limit.o diff --git a/src/conf_post.h b/src/conf_post.h index 176ab28b21..8558dc466c 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -99,10 +99,28 @@ typedef bool bool_bf; # define ADDRESS_SANITIZER false #endif +#ifdef emacs +/* We include stdlib.h here, because Gnulib's stdlib.h might redirect + 'free' to its replacement, and we want to avoid that in unexec + builds. Inclduing it here will render its inclusion after config.h + a no-op. */ +# if (defined DARWIN_OS && defined HAVE_UNEXEC) || defined HYBRID_MALLOC +# include +# endif +#endif + #if defined DARWIN_OS && defined emacs && defined HAVE_UNEXEC +# undef malloc # define malloc unexec_malloc +# undef realloc # define realloc unexec_realloc +# undef free # define free unexec_free + +extern void *unexec_malloc (size_t); +extern void *unexec_realloc (void *, size_t); +extern void unexec_free (void *); + #endif /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use @@ -111,12 +129,23 @@ typedef bool bool_bf; accomplish this. */ #ifdef HYBRID_MALLOC #ifdef emacs +#undef malloc #define malloc hybrid_malloc +#undef realloc #define realloc hybrid_realloc +#undef aligned_alloc #define aligned_alloc hybrid_aligned_alloc +#undef calloc #define calloc hybrid_calloc +#undef free #define free hybrid_free -#endif + +extern void *hybrid_malloc (size_t); +extern void *hybrid_calloc (size_t, size_t); +extern void hybrid_free (void *); +extern void *hybrid_aligned_alloc (size_t, size_t); +extern void *hybrid_realloc (void *, size_t); +#endif /* emacs */ #endif /* HYBRID_MALLOC */ /* We have to go this route, rather than the old hpux9 approach of diff --git a/src/gmalloc.c b/src/gmalloc.c index 66008ea69b..dedd25fa22 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -1690,16 +1690,6 @@ valloc (size_t size) #undef free #ifdef HYBRID_MALLOC -/* Declare system malloc and friends. */ -extern void *malloc (size_t size); -extern void *realloc (void *ptr, size_t size); -extern void *calloc (size_t nmemb, size_t size); -extern void free (void *ptr); -#ifdef HAVE_ALIGNED_ALLOC -extern void *aligned_alloc (size_t alignment, size_t size); -#elif defined HAVE_POSIX_MEMALIGN -extern int posix_memalign (void **memptr, size_t alignment, size_t size); -#endif /* Assuming PTR was allocated via the hybrid malloc, return true if PTR was allocated via gmalloc, not the system malloc. Also, return commit d68f2b8681f8eeb6bbf1b4476a88f00b2962179e Author: Eli Zaretskii Date: Thu May 20 09:55:28 2021 +0300 ; * src/fns.c (Fline_number_at_pos): Fix doc string and comments. diff --git a/src/fns.c b/src/fns.c index 41429c8863..e244268573 100644 --- a/src/fns.c +++ b/src/fns.c @@ -5892,12 +5892,14 @@ in OBJECT. */) DEFUN ("line-number-at-pos", Fline_number_at_pos, Sline_number_at_pos, 0, 2, 0, - doc: /* Return the line number at POSITION. -If POSITION is nil, use the current buffer location. - -If the buffer is narrowed, the position returned is the position in the -visible part of the buffer. If ABSOLUTE is non-nil, count the lines -from the absolute start of the buffer. */) + doc: /* Return the line number at POSITION in the current buffer. +If POSITION is nil or omitted, it defaults to point's position in the +current buffer. + +If the buffer is narrowed, the return value by default counts the lines +from the beginning of the accessible portion of the buffer. But if the +second optional argument ABSOLUTE is non-nil, the value counts the lines +from the absolute start of the buffer, disregarding the narrowing. */) (register Lisp_Object position, Lisp_Object absolute) { ptrdiff_t pos, start = BEGV_BYTE; @@ -5915,7 +5917,7 @@ from the absolute start of the buffer. */) if (!NILP (absolute)) start = BEG_BYTE; - /* Check that POSITION is n the visible range of the buffer. */ + /* Check that POSITION is in the accessible range of the buffer. */ if (pos < BEGV || pos > ZV) args_out_of_range (make_int (start), make_int (ZV)); commit 6ae3f7e889434eb8f76cc376d2939c66eb470855 Author: Tassilo Horn Date: Wed May 19 21:21:03 2021 +0200 Add a section about bug-reference-mode. * doc/emacs/maintaining.texi (Maintaining): Add a section about bug-reference-mode. * doc/emacs/emacs.texi (Top): Link to the new section about bug-reference-mode. diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index e0de3bb43a..9f64456a10 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi @@ -795,6 +795,8 @@ Maintaining Large Programs @ifnottex * Emerge:: A convenient way of merging two versions of a program. @end ifnottex +* Bug Reference:: Highlighting references to bug reports and browsing + them in their issue trackers. Version Control diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 0065098976..dc24cfb449 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -32,6 +32,10 @@ symbols (a.k.a.@: ``identifiers'') and their references. A mode for merging changes to program sources made on separate branches of development. @end ifnottex + +@item +A minor-mode for highlighting bug references and visiting the +referenced bug reports in their issue tracker. @end itemize If you are maintaining a large Lisp program, then in addition to the @@ -49,6 +53,8 @@ Lisp Regression Testing}). @ifnottex * Emerge:: A convenient way of merging two versions of a program. @end ifnottex +* Bug Reference:: Highlighting references to bug reports and browsing + them in their issue trackers. @end menu @node Version Control @@ -3053,3 +3059,52 @@ the target should be built. @ifnottex @include emerge-xtra.texi @end ifnottex + + +@node Bug Reference +@section Bug Reference +@cindex bug reference + + Most projects with a certain amount of users track bug reports in +some issue tracking software which assigns each report a unique and +short number or identifier. Those are used to reference a given bug, +e.g., in a source code comment above the code fixing some bug, in +documentation files, or in discussions on some mailinglist or IRC +channel. + +@findex bug-reference-mode +@findex bug-reference-prog-mode +The minor modes @code{bug-reference-mode} and +@code{bug-reference-prog-mode} highlight such bug references and make +it possible to follow them to the corresponding bug report on the +project's issue tracker. @code{bug-reference-prog-mode} is a variant +of @code{bug-reference-mode} which highlights bug references only +inside source code comments and strings. + +For its working, bug reference mode needs to know the syntax of bug +references (@code{bug-reference-bug-regexp}), and the URL of the +tracker where bug reports can be looked up +(@code{bug-reference-url-format}). Since those are typically +different from project to project, it makes sense to specify them in +@pxref{Directory Variables} or @pxref{File Variables}. + +For example, let's assume in our project, we usually write references +to bug reports as bug#1234, or Bug-1234 and that this bug's page on +the issue tracker is https://project.org/issues/1234, then these local +variables section would do. + +@smallexample +;; Local Variables: +;; bug-reference-bug-regexp: "\\([Bb]ug[#-]\\)\\([0-9]+\\)" +;; bug-reference-url-format: "https://project.org/issues/%s" +;; End: +@end smallexample + +The string captured by the second regexp group in +(@code{bug-reference-bug-regexp}) is used to replace the @code{%s} +template in the @code{bug-reference-url-format}. + +Note that @code{bug-reference-url-format} may also be a function in +order to cater for more complex scenarios, e.g., when the part before +the actual bug number has to be used to distinguish between issues and +merge requests where each of them has a different URL. commit 1f0f922ef279e29bc91642f4e8ff2b552064d07f Author: Juri Linkov Date: Wed May 19 19:30:33 2021 +0300 * lisp/simple.el (yank-from-kill-ring-rotate): New defcustom (bug#48478). (read-from-kill-ring, yank-from-kill-ring): Use it. diff --git a/etc/NEWS b/etc/NEWS index 8bbb972493..32d7c4fe18 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -340,7 +340,8 @@ When invoked like that, it prompts in the minibuffer for one of the previous kills, offering completion and minibuffer-history navigation through previous kills recorded in the kill ring. A similar feature in Isearch can be invoked if you bind 'C-s M-y' to the command -'isearch-yank-pop'. +'isearch-yank-pop'. When the user option 'yank-from-kill-ring-rotate' +is nil the kill ring is not rotated after 'yank-from-kill-ring'. --- ** New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay'. diff --git a/lisp/simple.el b/lisp/simple.el index 2d9b7dddab..8697eed9e3 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5683,6 +5683,9 @@ PROMPT is a string to prompt with." ;; `current-kill' updates `kill-ring' with a possible interprogram-paste (current-kill 0) (let* ((history-add-new-input nil) + (history-pos (when yank-from-kill-ring-rotate + (- (length kill-ring) + (length kill-ring-yank-pointer)))) (ellipsis (if (char-displayable-p ?…) "…" "...")) ;; Remove keymaps from text properties of copied string, ;; because typing RET in the minibuffer might call @@ -5730,7 +5733,16 @@ PROMPT is a string to prompt with." '(metadata (display-sort-function . identity)) (complete-with-action action completions string pred))) nil nil nil - 'read-from-kill-ring-history)))) + (if history-pos + (cons 'read-from-kill-ring-history history-pos) + 'read-from-kill-ring-history))))) + +(defcustom yank-from-kill-ring-rotate t + "Whether using `yank-from-kill-ring' should rotate `kill-ring-yank-pointer'. +If non-nil, the kill ring is rotated after selecting previously killed text." + :type 'boolean + :group 'killing + :version "28.1") (defun yank-from-kill-ring (string &optional arg) "Select a stretch of previously killed text and insert (\"paste\") it. @@ -5755,12 +5767,19 @@ beginning of the inserted text and mark at the end, like `yank' does. When called from Lisp, insert STRING like `insert-for-yank' does." (interactive (list (read-from-kill-ring "Yank from kill-ring: ") current-prefix-arg)) + (setq yank-window-start (window-start)) (push-mark) (insert-for-yank string) + (when yank-from-kill-ring-rotate + (let ((pos (seq-position kill-ring string))) + (setq kill-ring-yank-pointer + (or (and pos (nthcdr (1+ pos) kill-ring)) + kill-ring)))) (if (consp arg) - ;; Swap point and mark like in `yank'. + ;; Swap point and mark like in `yank' and `yank-pop'. (goto-char (prog1 (mark t) (set-marker (mark-marker) (point) (current-buffer)))))) + ;; Some kill commands. commit 171dbe704890a16cb7381afd7461f6138481ade8 Author: Eli Zaretskii Date: Wed May 19 19:01:07 2021 +0300 Fix rare failures in 'window-default-font-height' * lisp/window.el (window-default-font-height): Avoid signaling an error when a client TTY frame happens to have an X-style 'display' parameter. (Bug#48408) diff --git a/lisp/window.el b/lisp/window.el index 1c719480ca..0f94d8a214 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8788,7 +8788,11 @@ font on WINDOW's frame." (let* ((window (window-normalize-window window t)) (frame (window-frame window)) (default-font (face-font 'default frame))) - (if (and (display-multi-font-p (frame-parameter frame 'display)) + ;; Client frames can have the 'display' parameter set like for X + ;; frames, even though they are TTY frames, so make sure we won't + ;; be duped by that up front with 'framep'. + (if (and (not (eq (framep frame) t)) + (display-multi-font-p (frame-parameter frame 'display)) (not (string-equal (frame-parameter frame 'font) default-font))) (aref (font-info default-font frame) 3) (frame-char-height frame)))) commit eb9f48bfade95c0e0f23cd192526d7932939bc7a Author: Eli Zaretskii Date: Wed May 19 18:56:27 2021 +0300 * lisp/startup.el (command-line-1): Avoid byte-compiler warning. diff --git a/lisp/startup.el b/lisp/startup.el index 2ba5d74554..ac319612e8 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2317,6 +2317,9 @@ A fancy display is used on graphic displays, normal otherwise." (set-buffer-major-mode (current-buffer)) (current-buffer)))) +;; This avoids byte-compiler warning in the unexec build. +(declare-function pdumper-stats "pdumper.c" ()) + (defun command-line-1 (args-left) "A subroutine of `command-line'." (display-startup-echo-area-message) commit e100ee84e358755c0dc8a449091bde28603970c6 Author: Glenn Morris Date: Wed May 19 08:28:35 2021 -0700 Fix custom type of recent dired-aux additions * lisp/dired-aux.el (dired-compress-file-default-suffix) (dired-compress-directory-default-suffix): Fix :type. diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index eb43ab187d..d57237f038 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1169,7 +1169,7 @@ ARGS are command switches passed to PROGRAM.") (defcustom dired-compress-file-default-suffix nil "Default suffix for compressing a single file. If nil, \".gz\" will be used." - :type 'string + :type '(choice (const :tag ".gz" nil) string) :group 'dired :version "28.1") @@ -1190,7 +1190,7 @@ output file. %i path(s) are relative, while %o is absolute.") (defcustom dired-compress-directory-default-suffix nil "Default suffix for compressing a directory. If nil, \".tar.gz\" will be used." - :type 'string + :type '(choice (const :tag ".tar.gz" nil) string) :group 'dired :version "28.1") commit b4e1fdfe2128c53be61f04d7c35995eb1e5fb57f Author: Stefan Monnier Date: Wed May 19 11:19:10 2021 -0400 * lisp/kmacro.el (kmacro-lambda-form): Fix bug#48523 Re-add `counter` and `format` arguments, since they are used in `insert-kbd-macro`. diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 3700a1964a..afc486f4ed 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -782,17 +782,23 @@ If kbd macro currently being defined end it before activating it." ;; executing the macro later on (but that's controversial...) ;;;###autoload -(defun kmacro-lambda-form (mac) +(defun kmacro-lambda-form (mac &optional counter format) "Create lambda form for macro bound to symbol or key." - ;; FIXME: This should be a "funcallable struct"! - (lambda (&optional arg) - "Keyboard macro." - ;; We put an "unused prompt" as a special marker so - ;; `kmacro-extract-lambda' can see it's "one of us". - (interactive "pkmacro") - (if (eq arg 'kmacro--extract-lambda) - (cons 'kmacro--extract-lambda mac) - (kmacro-exec-ring-item mac arg)))) + ;; Apparently, there are two different ways this is called: + ;; either `counter' and `format' are both provided and `mac' is a vector, + ;; or only `mac' is provided, as a list (MAC COUNTER FORMAT). + ;; The first is used from `insert-kbd-macro' and `edmacro-finish-edit', + ;; while the second is used from within this file. + (let ((mac (if counter (list mac counter format) mac))) + ;; FIXME: This should be a "funcallable struct"! + (lambda (&optional arg) + "Keyboard macro." + ;; We put an "unused prompt" as a special marker so + ;; `kmacro-extract-lambda' can see it's "one of us". + (interactive "pkmacro") + (if (eq arg 'kmacro--extract-lambda) + (cons 'kmacro--extract-lambda mac) + (kmacro-exec-ring-item mac arg))))) (defun kmacro-extract-lambda (mac) "Extract kmacro from a kmacro lambda form." commit 5e1a8d5654d97d2631ad67ebb88be4d2eec7d408 Author: Eli Zaretskii Date: Wed May 19 17:42:50 2021 +0300 Fix the unexec build on GNU/Linux The unexec build on GNU/Linux must use HYBRID_MALLOC (gmalloc.c) and sheap.c. This was inadvertently disabled because a configure-time test for 'sbrk' was moved as side effect of an unrelated change. * configure.ac: Test for 'sbrk' before using the result in the decision about SYSTEM_MALLOC and HYBRID_MALLOC. (HYBRID_MALLOC): Prevent Gnulib from redirecting 'free' to its replacement 'rpl_free'. * lib/Makefile.in (not_emacs_OBJECTS): Add mallooc/%.o and free.o. diff --git a/configure.ac b/configure.ac index 3df4359fa7..d35ac6dbd3 100644 --- a/configure.ac +++ b/configure.ac @@ -2273,6 +2273,9 @@ doug_lea_malloc=$emacs_cv_var_doug_lea_malloc hybrid_malloc= system_malloc=yes +dnl This must be before the test of $ac_cv_func_sbrk below. +AC_CHECK_FUNCS_ONCE([sbrk]) + test $with_unexec = yes && case "$opsys" in ## darwin ld insists on the use of malloc routines in the System framework. @@ -2306,6 +2309,9 @@ elif test "$hybrid_malloc" = yes; then GNU_MALLOC_reason=" (only before dumping)" GMALLOC_OBJ=gmalloc.o VMLIMIT_OBJ= + # FIXME: This is to prevent Gnulib from redirecting 'free' to its + # replacement, instead of 'hybrid_free' in gmalloc.c. + gl_cv_func_free_preserves_errno=yes else test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o VMLIMIT_OBJ=vm-limit.o @@ -4677,7 +4683,7 @@ AC_CHECK_HEADERS(valgrind/valgrind.h) AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include ]]) -AC_CHECK_FUNCS_ONCE([__lsan_ignore_object sbrk]) +AC_CHECK_FUNCS_ONCE([__lsan_ignore_object]) AC_FUNC_FORK diff --git a/lib/Makefile.in b/lib/Makefile.in index 6c7a443099..ec92f92fb3 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -69,7 +69,9 @@ Makefile: ../config.status $(srcdir)/Makefile.in # Object modules that need not be built for Emacs. # Emacs does not need e-regex.o (it has its own regex-emacs.c), # and building it would just waste time. -not_emacs_OBJECTS = regex.o +# Emacs also doesn't need the dynarray-related files in malloc/ and +# the replacement 'free'. +not_emacs_OBJECTS = regex.o malloc/%.o free.o libgnu_a_OBJECTS = fingerprint.o $(gl_LIBOBJS) \ $(patsubst %.c,%.o,$(filter %.c,$(libgnu_a_SOURCES))) commit dac694b8bb1e5a31a50215ceee6b064ae7c5001f Author: Ingo Lohmar Date: Wed May 19 15:02:33 2021 +0200 * lisp/progmodes/sql.el: `sql-postgres-statement-starters' defcustom Recognize common table expression as statement start in Postgres. diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 83cb77ef78..2bfb222182 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -484,6 +484,7 @@ file. Since that is a plaintext file, this could be dangerous." :prompt-regexp "^[[:alnum:]_]*=[#>] " :prompt-length 5 :prompt-cont-regexp "^[[:alnum:]_]*[-(][#>] " + :statement sql-postgres-statement-starters :input-filter sql-remove-tabs-filter :terminator ("\\(^\\s-*\\\\g\\|;\\)" . "\\g")) @@ -1239,6 +1240,13 @@ add your name with a \"-U\" prefix (such as \"-Umark\") to the list." (push (match-string 1 row) res)))) (nreverse res)))) +(defcustom sql-postgres-statement-starters + (regexp-opt '("with")) + "Additional statement-starting keywords in Postgres." + :type 'string + :group 'SQL + :version "28.1") + ;; Customization for Interbase (defcustom sql-interbase-program "isql" commit 61291e06cc804de2075305c220d31ef6072f28c8 Author: Mauro Aranda Date: Wed May 19 09:57:46 2021 -0300 Lift restriction for finding theme summary line * lisp/cus-theme.el (custom-theme-summary): Don't limit the file to having the deftheme form as the very first form, rather look for the deftheme form explicitly. diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el index 13fb9f34fa..dfa2226403 100644 --- a/lisp/cus-theme.el +++ b/lisp/cus-theme.el @@ -657,10 +657,12 @@ Theme files are named *-theme.el in `")) (insert-file-contents fn) (let ((sexp (let ((read-circle nil)) (condition-case nil - (read (current-buffer)) - (end-of-file nil))))) - (and (eq (car-safe sexp) 'deftheme) - (setq doc (nth 2 sexp)))))))) + (progn + (re-search-forward "^(deftheme") + (beginning-of-line) + (read (current-buffer))) + (error nil))))) + (setq doc (nth 2 sexp))))))) (cond ((null doc) "(no documentation available)") ((string-match ".*" doc)