Re: Value or symbol handler with max argument error fix
Jean Louis <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Organization | GNU Support |
| Message-ID | <[email protected]> |
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?
(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