profiler-report 怎么修改function列的宽度啊

记得这个问题我曾经回答过一次:lsp-ui启动速度问题 - #5,来自 twlz0ne

刚才顺便写了一个 resize 函数:

(defun dotemacs/profile-resize-report-view (&optional width)
  "Resize profile report view and set function column width to WIDTH.
If there is no WIDTH input, expand function column to fit `window-width'."
  (interactive)
  (unless (eq major-mode 'profiler-report-mode)
    (signal 'error (list "Not a Profiler Report buffer.")))
  (let* ((buffer (current-buffer))
         (type (if (string-prefix-p "*CPU-Profiler-Report " (buffer-name)) 'cpu 'memory))
         (format-sym (intern (format "profiler-report-%s-line-format" type)))
         (profiler-fun (intern (format "profiler-%s-profile" type))) 
         (width (or width
                    (read-number "Function column width: "
                                 (pcase (symbol-value format-sym)
                                   (`((,_ left) (,right right . ,_))
                                    (- (window-width) (line-number-display-width) right)))))))
    (eval `(let ((,format-sym
                  '((,width left) ,(cadr (symbol-value format-sym)))))
             (switch-to-buffer (profiler-report-setup-buffer (funcall ',profiler-fun)))))
    (kill-buffer buffer)))

M-x dotemacs/profile-resize-report-view 然后指定宽度,或者默认自适应窗口宽度。

1 个赞