Re: Value or symbol handler with max argument error fix
Heime <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <Z23E6ptXeO-lDDdX0rowcSBjWFrVNd3fvq3qzxO23KPrZp0nEhGmyebYWqX9X51Z1JkIlHpPOi07o4aufgydm-l0p7JrN-3DO6e3-TlbHpI=@protonmail.com> |
On Monday, April 13th, 2026 at 7:36 AM, Jean Louis <[email protected]> wrote: > On 2026-04-12 14:13, Heime wrote: > > I want to pass either a symbol or the value to lana-du-fpln. > > > > (lana-du-fpln myplist) > > (lana-du-fpln 'myplist) > > > > I am getting Lisp error: (wrong-number-of-arguments #<subr max> 0) > > max() > > apply(max nil) > > (max 5 (apply #'max kl)) > > > > for this function > > > > (defun lana-du-fpln (datenstruk) > > "Display HASH-TABLE contents in a dedicated buffer." > > > > (let* ( (bfr (get-buffer-create (or bname "Lana DU"))) > > > > (dtnm (if (symbolp datenstruk) (symbol-name datenstruk) > > "Anonymous")) > > (dtvl (if (symbolp datenstruk) (symbol-value datenstruk) > > datenstruk)) > > > > ;; Display width using key lengths > > (kl (map-apply > > (lambda (key _value) (length (format "%s" key))) > > dtvl)) > > (wl (max 5 (apply #'max kl))) > > > > (gwidth 2) > > (fmt-str (format "%%-%ds | %%-%ds | %%s\n" gwidth kwmax)) ) > > > > (with-current-buffer bfr > > (read-only-mode 0) > > (erase-buffer) > > > > (map-do > > ;; FUNCITON > > (lambda (key value) > > (let* ( (fkey (format "%s" key)) > > (fval (format "%s" value)) > > (sgnl (if (file-directory-p fval) > > (propertize " " 'face lmps) > > (propertize " " 'face lmpw))) > > (pkey (if (file-directory-p fval) > > (propertize fkey 'face gjsf) > > (propertize fkey 'face gjwf))) ) > > (insert (format fmt-str sgnl pkey fval)))) > > ;; MAP Data Structure (HASH-TABLE/PLIST/ALIST) > > dtvl) > > > > (goto-char (point-min))) > > > > (pop-to-buffer bfr))) > > kl being something other than a list of numbers? Have simplified the code to call simple external functions. The update solved my problem. kl should have been a list of numbers (lengths). > (lana-du-fpln myplist) > (lana-du-fpln 'myplist) > > | :a | 1 > | :b | 2 > > > (defun lana-du-fpln (datenstruk) > "Display HASH-TABLE contents in a dedicated buffer." > > (let* ( (bfr (get-buffer-create "Lana DU")) > (dtnm (if (symbolp datenstruk) (symbol-name datenstruk) > "Anonymous")) > (dtvl (if (symbolp datenstruk) (symbol-value datenstruk) > datenstruk)) > > ;; Display width using key lengths > (kl (map-apply > (lambda (key _value) (length (format "%s" key))) > dtvl)) > ;; Handle empty data structure > (wl (if kl (max 5 (apply #'max kl)) 5)) > > (gwidth 2) > (fmt-str (format "%%-%ds | %%-%ds | %%s\n" gwidth wl)) ) > > (with-current-buffer bfr > (read-only-mode 0) > (erase-buffer) > > (when dtvl ; Only process if there's data > (map-do > ;; FUNCTION > (lambda (key value) > (let* ( (fkey (format "%s" key)) > (fval (format "%s" value)) > (sgnl (if (file-directory-p fval) > (propertize " " 'face 'lmps) > (propertize " " 'face 'lmpw))) > (pkey (if (file-directory-p fval) > (propertize fkey 'face 'gjsf) > (propertize fkey 'face 'gjwf))) ) > (insert (format fmt-str sgnl pkey fval)))) > ;; MAP Data Structure (HASH-TABLE/PLIST/ALIST) > dtvl)) > > (goto-char (point-min))) > > (pop-to-buffer bfr))) > > -- > Jean Louis > >