commit 268a3d32fb5a26c09787627d12a4dfc61ba059ff (HEAD, refs/remotes/origin/master) Author: Juri Linkov Date: Wed Dec 23 11:30:04 2020 +0200 Show image as text when trying to search/replace in image buffer (bug#25905) * lisp/image-mode.el (image-mode-isearch-filter): New function. (image-mode--setup-mode): Use it to add it as :before-while to isearch-filter-predicate. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 465bf86762..143b68f52e 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -667,6 +667,9 @@ Key bindings: (when image-auto-resize-on-window-resize (add-hook 'window-state-change-functions #'image--window-state-change nil t)) + (add-function :before-while (local 'isearch-filter-predicate) + #'image-mode-isearch-filter) + (run-mode-hooks 'image-mode-hook) (let ((image (image-get-display-property)) (msg1 (substitute-command-keys @@ -782,6 +785,14 @@ Remove text properties that display the image." (if (called-interactively-p 'any) (message "Repeat this command to go back to displaying the image")))) +(defun image-mode-isearch-filter (_beg _end) + "Show image as text when trying to search/replace in the image buffer." + (save-match-data + (when (and (derived-mode-p 'image-mode) + (image-get-display-property)) + (image-mode-as-text))) + t) + (defvar archive-superior-buffer) (defvar tar-superior-buffer) (declare-function image-flush "image.c" (spec &optional frame)) commit 5c86a5329664cd5fd3b81fe991c8d7dc18815e07 Author: Lars Ingebrigtsen Date: Wed Dec 23 07:59:24 2020 +0100 Improve the string-limit doc string * lisp/emacs-lisp/subr-x.el (string-limit): Mention truncate-string-to-width in the doc string. diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index e9e1be1d55..0067495fea 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -147,6 +147,9 @@ There can be any number of :example/:result elements." :eval (string-limit "foobar" 3) :eval (string-limit "foobar" 3 t) :eval (string-limit "foobar" 10)) + (truncate-string-to-width + :eval (truncate-string-to-width "foobar" 3) + :eval (truncate-string-to-width "你好bar" 5)) (split-string :eval (split-string "foo bar") :eval (split-string "|foo|bar|" "|") diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 8a9424cbb3..7e17a3464e 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -293,7 +293,11 @@ is returned unchanged. If STRING is longer than LENGTH, return a substring consisting of the first LENGTH characters of STRING. If END is non-nil, return -the last LENGTH characters instead." +the last LENGTH characters instead. + +When shortening strings for display purposes, +`truncate-string-to-width' is almost always a better alternative +than this function." (unless (natnump length) (signal 'wrong-type-argument (list 'natnump length))) (cond commit 22c1f00d997d38ba0c453da5f5e9c526d0ac05b0 Author: Lars Ingebrigtsen Date: Wed Dec 23 07:45:19 2020 +0100 Allow string-slice to take zero-length matches * lisp/emacs-lisp/subr-x.el (string-slice): Allow zero-length matches. Code adapted from s.el by Magnar Sveen. diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 09c4649817..8a9424cbb3 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -308,19 +308,16 @@ If OMIT-NULLS, empty lines will be removed from the results." (defun string-slice (string regexp) "Split STRING at REGEXP boundaries and return a list of slices. -The boundaries that match REGEXP are included in the result." - (let ((start-substring 0) - (start-search 0) - (result nil)) - (save-match-data - (while (string-match regexp string start-search) - (if (zerop (match-beginning 0)) - (setq start-search (match-end 0)) - (push (substring string start-substring (match-beginning 0)) result) - (setq start-substring (match-beginning 0) - start-search (match-end 0)))) - (push (substring string start-substring) result) - (nreverse result)))) +The boundaries that match REGEXP are included in the result. + +Also see `split-string'." + (if (zerop (length string)) + (list "") + (let ((i (string-match-p regexp string 1))) + (if i + (cons (substring string 0 i) + (string-slice (substring string i) regexp)) + (list string))))) (defun string-pad (string length &optional padding start) "Pad STRING to LENGTH using PADDING. diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index 854d61ed28..3fc5f1d3ed 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -608,7 +608,9 @@ (should (equal (string-slice "foo-bar" "-") '("foo" "-bar"))) (should (equal (string-slice "foo-bar-" "-") '("foo" "-bar" "-"))) (should (equal (string-slice "-foo-bar-" "-") '("-foo" "-bar" "-"))) - (should (equal (string-slice "ooo" "lala") '("ooo")))) + (should (equal (string-slice "ooo" "lala") '("ooo"))) + (should (equal (string-slice "foo bar" "\\b") '("foo" " " "bar" ""))) + (should (equal (string-slice "foo bar" "\\b\\|a") '("foo" " " "b" "ar" "")))) (ert-deftest subr-string-pad () (should (equal (string-pad "foo" 5) "foo ")) commit 21097cdd32a29a14ba3b1af55cffb1a9180faf26 Author: Lars Ingebrigtsen Date: Wed Dec 23 06:58:12 2020 +0100 Revert recent server.el frame-focus changes * lisp/server.el (server-switch-buffer, server-execute): Revert 9cef8fc8cdb5e6e18c9cf617eed3808d67ca340e and c5f2eb56c0164e87abc881955552e0b718921186. This change led to regressions in non-new-frame circumstances. diff --git a/lisp/server.el b/lisp/server.el index 7773da09c7..d1183b95d3 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1327,8 +1327,6 @@ The following commands are accepted by the client: (t (server-return-error proc err)))) (defun server-execute (proc files nowait commands dontkill frame tty-name) - (when server-raise-frame - (select-frame-set-input-focus (or frame (selected-frame)))) ;; This is run from timers and process-filters, i.e. "asynchronously". ;; But w.r.t the user, this is not really asynchronous since the timer ;; is run after 0s and the process-filter is run in response to the @@ -1688,7 +1686,9 @@ be a cons cell (LINENUMBER . COLUMNNUMBER)." (switch-to-buffer next-buffer)) ;; After all the above, we might still have ended up with ;; a minibuffer/dedicated-window (if there's no other). - (error (pop-to-buffer next-buffer))))))))) + (error (pop-to-buffer next-buffer))))))) + (when server-raise-frame + (select-frame-set-input-focus (window-frame))))) ;;;###autoload (defun server-save-buffers-kill-terminal (arg) commit 1e11f6f59d141f280b50905238a392faffdb134a Author: Łukasz Stelmach Date: Tue Dec 22 07:47:23 2020 +0100 Handle gracefully href="" in base tags in shr * net/shr.el (shr-tag-base): shr-parse-base can't handle empty strings gracefully. Don't call it unless href is a non-empty string (bug#45355). diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 2e5dd5ffa5..1648e56cfb 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1516,8 +1516,9 @@ ones, in case fg and bg are nil." plist))) (defun shr-tag-base (dom) - (when-let* ((base (dom-attr dom 'href))) - (setq shr-base (shr-parse-base base))) + (let ((base (dom-attr dom 'href))) + (when (> (length base) 0) + (setq shr-base (shr-parse-base base)))) (shr-generic dom)) (defun shr-tag-a (dom) commit 832d756893d1e1630e2477562057b01791b0bfc6 Author: Stefan Kangas Date: Wed Dec 23 05:16:02 2020 +0100 Fix use of obsolete 'emergency' warning level * src/alloc.c (display_malloc_warning): Use new style ':emergency' warning level instead of obsolete 'emergency'. diff --git a/src/alloc.c b/src/alloc.c index 5d2d5bc4ad..adbfa1883c 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -664,7 +664,7 @@ display_malloc_warning (void) call3 (intern ("display-warning"), intern ("alloc"), build_string (pending_malloc_warning), - intern ("emergency")); + intern (":emergency")); pending_malloc_warning = 0; } commit a649869d04826c5a669ee244a6681c6b5c09fa71 Author: Zajcev Evgeny Date: Tue Dec 22 17:37:38 2020 +0300 Fix use of obsolete 'error' warning level * src/fileio.c (auto_save_error): Use new style ':error' warning level instead of obsolete 'error'. diff --git a/src/fileio.c b/src/fileio.c index 51f12e104e..651e765fca 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5752,7 +5752,7 @@ auto_save_error (Lisp_Object error_val) Lisp_Object msg = CALLN (Fformat, format, BVAR (current_buffer, name), Ferror_message_string (error_val)); call3 (intern ("display-warning"), - intern ("auto-save"), msg, intern ("error")); + intern ("auto-save"), msg, intern (":error")); return Qnil; } commit 747a923b9a35533f98573ad5b01fccf096195079 Author: Alan Third Date: Tue Dec 22 23:28:25 2020 +0000 Use new NSString lisp methods * src/nsfont.m (ns_otf_to_script): (ns_registry_to_script): (ns_get_req_script): Use NSString conversion methods. * src/nsimage.m ([EmacsImage allocInitFromFile:]): Use NSString conversion methods. * src/nsmenu.m (ns_menu_show): Use NSString conversion methods. * src/nsselect.m (symbol_to_nsstring): (ns_string_to_pasteboard_internal): Use NSString conversion methods. * src/nsterm.m (ns_term_init): ([EmacsView initFrameFromEmacs:]): Use NSString conversion methods. * src/nsxwidget.m (nsxwidget_webkit_uri): (nsxwidget_webkit_title): (js_to_lisp): Use NSString conversion methods. (build_string_with_nsstr): Functionality replaced by NSString extensions. diff --git a/src/nsfont.m b/src/nsfont.m index 378a640840..9e4caca910 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -329,7 +329,7 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */ { Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist); return CONSP (script) - ? [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (XCDR ((script))))] + ? [NSString stringWithLispString: SYMBOL_NAME (XCDR ((script)))] : @""; } @@ -345,7 +345,7 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */ if (!strncmp (SSDATA (r), reg, SBYTES (r))) { script = XCDR (XCAR (rts)); - return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))]; + return [NSString stringWithLispString: SYMBOL_NAME (script)]; } rts = XCDR (rts); } @@ -370,8 +370,7 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */ { Lisp_Object key = XCAR (tmp), val = XCDR (tmp); if (EQ (key, QCscript) && SYMBOLP (val)) - return [NSString stringWithUTF8String: - SSDATA (SYMBOL_NAME (val))]; + return [NSString stringWithLispString: SYMBOL_NAME (val)]; if (EQ (key, QClang) && SYMBOLP (val)) return ns_lang_to_script (val); if (EQ (key, QCotf) && CONSP (val) && SYMBOLP (XCAR (val))) diff --git a/src/nsimage.m b/src/nsimage.m index f9fb368ba8..c47a2b2d64 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -262,7 +262,7 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file found = ENCODE_FILE (found); image = [[EmacsImage alloc] initByReferencingFile: - [NSString stringWithUTF8String: SSDATA (found)]]; + [NSString stringWithLispString: found]]; image->bmRep = nil; #ifdef NS_IMPL_COCOA @@ -278,7 +278,7 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; - [image setName: [NSString stringWithUTF8String: SSDATA (file)]]; + [image setName: [NSString stringWithLispString: file]]; return image; } diff --git a/src/nsmenu.m b/src/nsmenu.m index a286a80da1..efad978316 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -970,7 +970,7 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f } pmenu = [[EmacsMenu alloc] initWithTitle: - [NSString stringWithUTF8String: SSDATA (title)]]; + [NSString stringWithLispString: title]]; [pmenu fillWithWidgetValue: first_wv->contents]; free_menubar_widget_value_tree (first_wv); unbind_to (specpdl_count, Qnil); diff --git a/src/nsselect.m b/src/nsselect.m index 7b1937f5d9..95fce4d0f7 100644 --- a/src/nsselect.m +++ b/src/nsselect.m @@ -58,7 +58,7 @@ Updated by Christian Limpach (chris@nice.ch) if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; if (EQ (sym, QTEXT)) return NSPasteboardTypeString; - return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))]; + return [NSString stringWithLispString: SYMBOL_NAME (sym)]; } static NSPasteboard * @@ -170,17 +170,12 @@ Updated by Christian Limpach (chris@nice.ch) } else { - char *utfStr; NSString *type, *nsStr; NSEnumerator *tenum; CHECK_STRING (str); - utfStr = SSDATA (str); - nsStr = [[NSString alloc] initWithBytesNoCopy: utfStr - length: SBYTES (str) - encoding: NSUTF8StringEncoding - freeWhenDone: NO]; + nsStr = [NSString stringWithLispString: str]; // FIXME: Why those 2 different code paths? if (gtype == nil) { @@ -196,7 +191,6 @@ Updated by Christian Limpach (chris@nice.ch) eassert (gtype == NSPasteboardTypeString); [pb setString: nsStr forType: gtype]; } - [nsStr release]; ns_store_pb_change_count (pb); } } diff --git a/src/nsterm.m b/src/nsterm.m index 7972fa4dab..2a117a0780 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5541,9 +5541,8 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes. /* There are 752 colors defined in rgb.txt. */ if ( cl == nil || [[cl allKeys] count] < 752) { - Lisp_Object color_file, color_map, color; + Lisp_Object color_file, color_map, color, name; unsigned long c; - char *name; color_file = Fexpand_file_name (build_string ("rgb.txt"), Fsymbol_value (intern ("data-directory"))); @@ -5556,14 +5555,14 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes. for ( ; CONSP (color_map); color_map = XCDR (color_map)) { color = XCAR (color_map); - name = SSDATA (XCAR (color)); + name = XCAR (color); c = XFIXNUM (XCDR (color)); [cl setColor: [NSColor colorForEmacsRed: RED_FROM_ULONG (c) / 255.0 green: GREEN_FROM_ULONG (c) / 255.0 blue: BLUE_FROM_ULONG (c) / 255.0 alpha: 1.0] - forKey: [NSString stringWithUTF8String: name]]; + forKey: [NSString stringWithLispString: name]]; } /* FIXME: Report any errors writing the color file below. */ @@ -7619,8 +7618,7 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f [self registerForDraggedTypes: ns_drag_types]; tem = f->name; - name = [NSString stringWithUTF8String: - NILP (tem) ? "Emacs" : SSDATA (tem)]; + name = NILP (tem) ? @"Emacs" : [NSString stringWithLispString:tem]; [win setTitle: name]; /* toolbar support */ diff --git a/src/nsxwidget.m b/src/nsxwidget.m index dbd4cb29a6..915fd8b59c 100644 --- a/src/nsxwidget.m +++ b/src/nsxwidget.m @@ -296,8 +296,6 @@ - (void)userContentController:(WKUserContentController *)userContentController /* Xwidget webkit commands. */ -static Lisp_Object build_string_with_nsstr (NSString *nsstr); - bool nsxwidget_is_web_view (struct xwidget *xw) { @@ -309,14 +307,14 @@ - (void)userContentController:(WKUserContentController *)userContentController nsxwidget_webkit_uri (struct xwidget *xw) { XwWebView *xwWebView = (XwWebView *) xw->xwWidget; - return build_string_with_nsstr (xwWebView.URL.absoluteString); + return [xwWebView.URL.absoluteString lispString]; } Lisp_Object nsxwidget_webkit_title (struct xwidget *xw) { XwWebView *xwWebView = (XwWebView *) xw->xwWidget; - return build_string_with_nsstr (xwWebView.title); + return [xwWebView.title lispString]; } /* @Note ATS - Need application transport security in 'Info.plist' or @@ -350,15 +348,6 @@ - (void)userContentController:(WKUserContentController *)userContentController /* TODO: setMagnification:centeredAtPoint. */ } -/* Build lisp string */ -static Lisp_Object -build_string_with_nsstr (NSString *nsstr) -{ - const char *utfstr = [nsstr UTF8String]; - NSUInteger bytes = [nsstr lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - return make_string (utfstr, bytes); -} - /* Recursively convert an objc native type JavaScript value to a Lisp value. Mostly copied from GTK xwidget 'webkit_js_to_lisp'. */ static Lisp_Object @@ -367,7 +356,7 @@ - (void)userContentController:(WKUserContentController *)userContentController if (value == nil || [value isKindOfClass:NSNull.class]) return Qnil; else if ([value isKindOfClass:NSString.class]) - return build_string_with_nsstr ((NSString *) value); + return [(NSString *) value lispString]; else if ([value isKindOfClass:NSNumber.class]) { NSNumber *nsnum = (NSNumber *) value; @@ -407,7 +396,7 @@ - (void)userContentController:(WKUserContentController *)userContentController { NSString *prop_key = (NSString *) [keys objectAtIndex:i]; id prop_value = [nsdict valueForKey:prop_key]; - p->contents[i] = Fcons (build_string_with_nsstr (prop_key), + p->contents[i] = Fcons ([prop_key lispString], js_to_lisp (prop_value)); } XSETVECTOR (obj, p); commit 6af31fd71ff1a403c199c479577bcc145a547db1 Author: Alan Mackenzie Date: Tue Dec 22 18:34:24 2020 +0000 Align the word "Function" in profiler's headers over the actual functions * lisp/profiler.el (profiler-report-render-calltree-1): Replace two occurrences of "Function" with " Function". diff --git a/lisp/profiler.el b/lisp/profiler.el index b25eed05bd..1c843727cc 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -745,11 +745,11 @@ below entry at point." (cpu (profiler-report-header-line-format profiler-report-cpu-line-format - (list "Samples" "%") " " "Function")) + (list "Samples" "%") " " " Function")) (memory (profiler-report-header-line-format profiler-report-memory-line-format - (list "Bytes" "%") " " "Function")))) + (list "Bytes" "%") " " " Function")))) (let ((predicate (cl-ecase order (ascending #'profiler-calltree-count<) (descending #'profiler-calltree-count>)))) commit aae44a36f35cc8bdefe86daf78fb9aa03df72c3a Author: Eric Abrahamsen Date: Sun Dec 20 11:26:37 2020 -0800 Ensure that Gnus servers are open(able) before searching them * lisp/gnus/gnus-search.el (gnus-search-run-search): Imap servers need to be opened (made into the "current server") before we manipulate the nnimap-buffer. (gnus-search-run-search): Sneakily fix regexp. (gnus-search-indexed-parse-output): We need to pass the server name in here, otherwise nnmaildir won't know how to make this the "current server". diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 16f3a024aa..3a3722c90a 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -1050,6 +1050,7 @@ Responsible for handling and, or, and parenthetical expressions.") (grouplist (or groups (gnus-search-get-active srv))) q-string artlist group) (message "Opening server %s" server) + (gnus-open-server srv) ;; We should only be doing this once, in ;; `nnimap-open-connection', but it's too frustrating to try to ;; get to the server from the process buffer. @@ -1071,7 +1072,7 @@ Responsible for handling and, or, and parenthetical expressions.") ;; A bit of backward-compatibility slash convenience: if the ;; query string doesn't start with any known IMAP search ;; keyword, assume it is a "TEXT" search. - (unless (and (string-match "\\`[^ [:blank:]]+" q-string) + (unless (and (string-match "\\`[^[:blank:]]+" q-string) (memql (intern-soft (downcase (match-string 0 q-string))) gnus-search-imap-search-keys)) @@ -1424,7 +1425,7 @@ Returns a list of [group article score] vectors." (string-to-number article) (nnmaildir-base-name-to-article-number (substring article 0 (string-match ":" article)) - group nil)) + group (string-remove-prefix "nnmaildir:" server))) (if (numberp score) score (string-to-number score))) commit 9449b81f2761661f1e3a9187906c00f95b6f6ebd Author: Alan Mackenzie Date: Tue Dec 22 16:57:46 2020 +0000 Align profiler's header-line-format to column 0, to work correctly on tty's * lisp/profiler.el (profiler-report-header-line-format): Propertize the first space with 'display '(space :align-to 0). diff --git a/lisp/profiler.el b/lisp/profiler.el index 13ac040f56..b25eed05bd 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -448,7 +448,7 @@ Optional argument MODE means only check for the specified mode (cpu or mem)." :group 'profiler) (defvar profiler-report-cpu-line-format - '((14 right ((9 right) + '((17 right ((12 right) (5 right))) (1 left "%s") (0 left))) @@ -500,7 +500,11 @@ RET: expand or collapse")) (defun profiler-report-header-line-format (fmt &rest args) (let* ((header (apply #'profiler-format fmt args)) (escaped (replace-regexp-in-string "%" "%%" header))) - (concat " " escaped))) + (concat + (propertize " " + 'display '(space :align-to 0) + 'face 'fixed-pitch) + escaped))) (defun profiler-report-line-format (tree) (let ((diff-p (profiler-profile-diff-p profiler-report-profile)) commit 9920929e7b538f8bf8fb1dd7a9ae7cd1fe5d2b31 Author: Alan Mackenzie Date: Tue Dec 22 12:06:21 2020 +0000 Re-order the items in `profiler-report' output. Putting the usage figures first on the line will eliminate the truncation of function names. lisp/profiler.el (profiler-version): Change to "28.1". (profiler-format): Enhance, so that a width of zero means print the string without padding or truncation. (profiler-report-cpu-line-format, profiler-report-memory-line-format): Amend for the new layout. The number of places for the cpu samples has been reduced from 19 to 12 (enough for ~30 years at 1,000 samples per second). (profiler-report-line-format, profiler-report-describe-entry): Amend for the new order of arguments to profiler-format. etc/NEWS (Specialized Modes): Add an entry documenting this change. doc/lispref/debugging.texi (Profiling): Describe the new ordering of the items in place of the old ordering. diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index 3fea604184..661961f937 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi @@ -1009,13 +1009,14 @@ profiling, so we don't recommend leaving it active except when you are actually running the code you want to examine). The profiler report buffer shows, on each line, a function that was -called, followed by how much resources (cpu or memory) it used in +called, preceded by how much resources (cpu or memory) it used in absolute and percentage terms since profiling started. If a given -line has a @samp{+} symbol at the left-hand side, you can expand that -line by typing @kbd{@key{RET}}, in order to see the function(s) called -by the higher-level function. Use a prefix argument (@kbd{C-u -@key{RET}}) to see the whole call tree below a function. Pressing -@kbd{@key{RET}} again will collapse back to the original state. +line has a @samp{+} symbol to the left of the function name, you can +expand that line by typing @kbd{@key{RET}}, in order to see the +function(s) called by the higher-level function. Use a prefix +argument (@kbd{C-u @key{RET}}) to see the whole call tree below a +function. Pressing @kbd{@key{RET}} again will collapse back to the +original state. Press @kbd{j} or @kbd{mouse-2} to jump to the definition of a function at point. Press @kbd{d} to view a function's documentation. You can diff --git a/etc/NEWS b/etc/NEWS index 46b8435a14..92493b70a0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -303,6 +303,14 @@ the buffer cycles the whole buffer between "only top-level headings", * Changes in Specialized Modes and Packages in Emacs 28.1 ++++ +** profiler.el +The results displayed by 'profiler-report' now have the usage figures +at the left hand side followed by the function name. This is intended +to make better use of the horizontal space, in particular eliminating +the truncation of function names. There is no way to get the former +layout back. + ** Loading dunnet.el in batch mode doesn't start the game any more. Instead you need to do "emacs -f dun-batch" to start the game in batch mode. diff --git a/lisp/profiler.el b/lisp/profiler.el index bf8aacccc3..13ac040f56 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -34,7 +34,7 @@ :version "24.3" :prefix "profiler-") -(defconst profiler-version "24.3") +(defconst profiler-version "28.1") (defcustom profiler-sampling-interval 1000000 "Default sampling interval in nanoseconds." @@ -85,6 +85,9 @@ (t (profiler-ensure-string arg))) for len = (length str) + if (zerop width) + collect str into frags + else if (< width len) collect (progn (put-text-property (max 0 (- width 2)) len 'invisible 'profiler str) @@ -445,14 +448,16 @@ Optional argument MODE means only check for the specified mode (cpu or mem)." :group 'profiler) (defvar profiler-report-cpu-line-format - '((50 left) - (24 right ((19 right) - (5 right))))) + '((14 right ((9 right) + (5 right))) + (1 left "%s") + (0 left))) (defvar profiler-report-memory-line-format - '((55 left) - (19 right ((14 right profiler-format-number) - (5 right))))) + '((20 right ((15 right profiler-format-number) + (5 right))) + (1 left "%s") + (0 left))) (defvar-local profiler-report-profile nil "The current profile.") @@ -505,13 +510,14 @@ RET: expand or collapse")) (profiler-format (cl-ecase (profiler-profile-type profiler-report-profile) (cpu profiler-report-cpu-line-format) (memory profiler-report-memory-line-format)) - name-part (if diff-p (list (if (> count 0) (format "+%s" count) count) "") - (list count count-percent))))) + (list count count-percent)) + " " + name-part))) (defun profiler-report-insert-calltree (tree) (let ((line (profiler-report-line-format tree))) @@ -735,11 +741,11 @@ below entry at point." (cpu (profiler-report-header-line-format profiler-report-cpu-line-format - "Function" (list "CPU samples" "%"))) + (list "Samples" "%") " " "Function")) (memory (profiler-report-header-line-format profiler-report-memory-line-format - "Function" (list "Bytes" "%"))))) + (list "Bytes" "%") " " "Function")))) (let ((predicate (cl-ecase order (ascending #'profiler-calltree-count<) (descending #'profiler-calltree-count>)))) commit 188b09d6d9b12a2ec7f8ed4ad4c0bd55acbb37b1 Author: Michael Albinus Date: Tue Dec 22 12:13:37 2020 +0100 Reorganize Tramp header lines * lisp/net/tramp.el: Move header lines Version, Package-Requires, Package-Type and URL ... * lisp/net/trampver.el: ... here. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 4d8118a728..0260569aa9 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -7,10 +7,6 @@ ;; Maintainer: Michael Albinus ;; Keywords: comm, processes ;; Package: tramp -;; Version: 2.5.0-pre -;; Package-Requires: ((emacs "25.1")) -;; Package-Type: multi -;; URL: https://savannah.gnu.org/projects/tramp ;; This file is part of GNU Emacs. diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el index d6b582edf8..30e5ba8151 100644 --- a/lisp/net/trampver.el +++ b/lisp/net/trampver.el @@ -7,6 +7,10 @@ ;; Maintainer: Michael Albinus ;; Keywords: comm, processes ;; Package: tramp +;; Version: 2.5.0-pre +;; Package-Requires: ((emacs "25.1")) +;; Package-Type: multi +;; URL: https://www.gnu.org/software/tramp/ ;; This file is part of GNU Emacs. @@ -30,10 +34,10 @@ ;;; Code: -;; In the Tramp GIT, the version number is auto-frobbed from tramp.el, -;; and the bug report address is auto-frobbed from configure.ac. -;; Emacs version check is defined in macro AC_EMACS_INFO of -;; aclocal.m4; should be changed only there. +;; In the Tramp GIT repository, the version number, the bug report +;; address and the required Emacs version are auto-frobbed from +;; configure.ac, so you should edit that file and run "autoconf && +;; ./configure" to change them. ;;;###tramp-autoload (defconst tramp-version "2.5.0-pre"