From: Eshel Yaron Date: Sat, 17 Feb 2024 07:45:09 +0000 (+0100) Subject: ; Ensure 'seq-max' argument is non empty X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=11d6dcd98b3cc68532f9b1d60fc39af309625bd2;p=emacs.git ; Ensure 'seq-max' argument is non empty * lisp/faces.el (completion-face-name-affixation) * lisp/minibuffer.el (completion-styles-affixation) (completion-file-name-affixation) (minibuffer-narrow-buffer-completions) (completion-buffer-name-affixation) * lisp/simple.el (read-extended-command--affixation): Add 0 to beginning of 'seq-max' argument to ensure it is non empty. --- diff --git a/lisp/faces.el b/lisp/faces.el index 272c714871f..2cbf1e56583 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -1143,11 +1143,11 @@ of `read-face-name-sample-text', which see." (samp-list (mapcar (lambda (name) (cons name (propertize text 'face name))) names)) - (max-samp (seq-max (mapcar #'string-pixel-width - (mapcar #'cdr samp-list))))) + (max-samp (seq-max (cons 0 (mapcar #'string-pixel-width + (mapcar #'cdr samp-list)))))) (if (eq (cdr-safe read-face-name-sample-text) 'after) ;; Sample comes after the face name. - (let ((max-name (seq-max (mapcar #'string-width names)))) + (let ((max-name (seq-max (cons 0 (mapcar #'string-width names))))) (lambda (name) (let* ((samp (cdr (assoc name samp-list))) (padw (- max-samp (string-pixel-width samp)))) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 911412e2b8c..d4b808b1584 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2756,7 +2756,7 @@ current order instead." (defun completion-styles-affixation (names) "Return completion affixations for completion styles list NAMES." - (let ((max-name (seq-max (mapcar #'string-width names)))) + (let ((max-name (seq-max (cons 0 (mapcar #'string-width names))))) (mapcar (lambda (name) (list name @@ -3576,7 +3576,7 @@ same as `substitute-in-file-name'." (defun completion-file-name-affixation (files) "Return completion affixations for file list FILES." - (let ((max-file (seq-max (mapcar #'string-width files)))) + (let ((max-file (seq-max (cons 0 (mapcar #'string-width files))))) (mapcar (lambda (file) (let ((full (substitute-in-file-name @@ -4063,7 +4063,7 @@ See `read-file-name' for the meaning of the arguments." (mapcar (apply-partially #'buffer-local-value 'major-mode) (mapcar #'get-buffer names)))))) - (max (seq-max (mapcar #'string-width modes))) + (max (seq-max (cons 0 (mapcar #'string-width modes)))) (name (completing-read "Restrict to mode: " @@ -4089,14 +4089,14 @@ See `read-file-name' for the meaning of the arguments." (defun completion-buffer-name-affixation (names) "Return completion affixations for buffer name list NAMES." - (let ((max-name (seq-max (mapcar #'string-width names))) + (let ((max-name (seq-max (cons 0 (mapcar #'string-width names)))) (max-mode (seq-max - (mapcar #'string-width - (mapcar #'symbol-name - (mapcar (apply-partially #'buffer-local-value - 'major-mode) - (mapcar #'get-buffer names))))))) + (cons 0 (mapcar #'string-width + (mapcar #'symbol-name + (mapcar (apply-partially #'buffer-local-value + 'major-mode) + (mapcar #'get-buffer names)))))))) (mapcar (lambda (name) (let* ((buf (get-buffer name)) diff --git a/lisp/simple.el b/lisp/simple.el index e80e33a9630..b36a04c93ef 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2480,9 +2480,9 @@ or (if one of MODES is a minor mode), if it is switched on in BUFFER." (eq (get-text-property (point) 'category) category)))) (defun read-extended-command--affixation (command-names) - (let* ((max-name (seq-max (mapcar #'string-width - (or (remove nil command-names) - '(""))))) + (let* ((max-name (seq-max + (cons 0 (mapcar #'string-width + (remove nil command-names))))) (bindings (when suggest-key-bindings (with-selected-window (or (minibuffer-selected-window) @@ -2496,9 +2496,9 @@ or (if one of MODES is a minor mode), if it is switched on in BUFFER." (cons fun (and binding (not (stringp binding)) (key-description binding))))) command-names)))) - (max-bind (seq-max (mapcar #'string-width - (or (remove nil (mapcar #'cdr bindings)) - '("")))))) + (max-bind (seq-max + (cons 0 (mapcar #'string-width + (remove nil (mapcar #'cdr bindings))))))) (mapcar (lambda (command-name) (let* ((fun (and (stringp command-name) (intern-soft command-name)))