Re: Value or symbol handler with max argument error fix

Heime <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <r668Ip1BQmRNPZ5zwHRvFUuzgBkgXuWohznHm7TkoSysRzxdsK_Nvh4MICBjOhhUH2v8EDwNTmq5NEkq7VpwKz5xvxI-GgjFwO_Ko4PitEA=@protonmail.com>
On Monday, April 13th, 2026 at 2:12 AM, tpeplt <[email protected]> wrote:

> Heime <[email protected]> writes:
> 
> > 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")))
> >
> 
> ‘bname’ is undefined in this function.
> 
> >           (dtnm   (if (symbolp datenstruk) (symbol-name datenstruk) "Anonymous"))
> 
> ‘dtnm’ is assigned a value but never used in this function.
> 
> >           (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)))
> 
> ‘wl’ is assigned a value but never used in this function.
> 
> If this variable is not needed in this function, then
> eliminating this assignment will resolve your run-time
> error.  The run-time error is occurring because your code
> does not account for the possibility that the value of ‘kl’
> could be an empty list (nil).
> 
> >
> > 	  (gwidth   2)
> > 	  (fmt-str  (format "%%-%ds | %%-%ds | %%s\n" gwidth kwmax)) )
> 
> ‘kwmax’ is undefined in this function.
> 
> >
> >     (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)
> 
> ‘lmps’ is undefined in this function.
> 
> >                             (propertize " " 'face lmpw)))
> 
> ‘lmpw’ is undefined in this function.
> 
> >                    (pkey  (if (file-directory-p fval)
> >                                 (propertize fkey 'face gjsf)
> 
> ‘gjsf’ is undefined in this function.
> 
> >                             (propertize fkey 'face gjwf))) )
> 
> ‘gjwf’ is undefined in this function.
> 
> >              (insert (format fmt-str sgnl pkey fval))))
> >         ;; MAP Data Structure (HASH-TABLE/PLIST/ALIST)
> >         dtvl)
> >
> >       (goto-char (point-min)))
> >
> >       (pop-to-buffer bfr)))
> >
> 
> You might consider moving the ‘(map-do ...)’ expression to
> its own function definition that is called with ‘dtvl’ as
> its argument.  Also, the near-duplicate code ‘(if
> (file-directory-p)...)’ might be a good candidate for a
> function that is called twice.

Have taken your suggestions to wove code to simple function
calls.  This simplified the embedding complexity, helping to
resolve many problems I have encountered with my implementation
of various options.
 
> --
> The lyf so short, the craft so long to lerne.
> - Geoffrey Chaucer, The Parliament of Birds.
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.