Xah Talk Show 2025-02-16 Ep614 emacs lisp coding, keyword parameters

vidthumb BvoZAUXl-Sg
vidthumb BvoZAUXl-Sg
Alice 2025-02-16 201647
Alice 2025-02-16 201647
PowerShell 2025-02-16 201304
PowerShell 2025-02-16 201304
(defun xtest (x &rest KeywordArgs)
  "testing keyword parameter. 3 keyword args. a, b, c."
  (interactive
   (let (xx xa xb xc)
     (setq xx (read-string "your name:"))
     (setq xa (read-string "val for xa:" ""))
     (setq xb (read-string "val for xb:" ""))
     (setq xc (read-string "val for xc:" ""))
     (list xx :a xa :b xb :c xc)))
  (let (a b c xresult)
    (setq a (if (or nil (string-equal (plist-get KeywordArgs :a) ""))
                0
              (plist-get KeywordArgs :a)))

    (setq b (or (plist-get KeywordArgs :b) 0))
    (setq c (or (plist-get KeywordArgs :c) 0))

    (message "value of KeywordArgs is 「%s」" KeywordArgs)
    (setq xresult (format "param values: x 「%s」, :a 「%s」, :b 「%s」, :c 「%s」" x a b c))
    (message xresult)
    xresult
    ))

(xtest 3 :a 5 :b 6 )

(message "%s" (list :aa nil :bb 3))

;; "param values: x 3, :a 5, :b 6, :c 0"


;; HHHH------------------------------

(xah-find-replace-text-regex "White Rabbit" "black Rabbit" "~/.emacs.d/temp/" "\\.txt\\'"
t
':fixed-search
':fixed-replace
':show-context
':backup)

(xtest "" ':a "" ':b "" ':c "")
(xah-find-text "haskell" "~/web/xahlee_info/talk_show/" "\\.html\\'" nil t)

(xah-find-text "haskell" "~/web/xahlee_info/talk_show/" "\\.html\\'"
fixedcase nil
printcontext t
)

(xah-find-text SEARCHSTR INPUTDIR PATHREGEX &optional FIXEDCASESEARCHQ
PRINTCONTEXT-P)