[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Avoiding code replication for hash-table
From: |
Heime |
Subject: |
Avoiding code replication for hash-table |
Date: |
Sat, 14 Sep 2024 19:11:34 +0000 |
I want to apply the current code for the alist to the hash-table
possibility as well (fpln can be a hash-table or alist).
But I cannot see how to accomplish this without replicating the code
for both conditions. Can something be done here ?
(defun torium-test-chart (bfrn fpln anctr)
(let* ( (bfrname (or bfrn "Torium F-Pln"))
(qbuffer (get-buffer-create bfrname)) )
(with-current-buffer qbuffer
(erase-buffer)
;; Print Waypoints and corresponding directory paths
(if (hash-table-p fpln)
;; ---------------------------------------------------
;; HASH-TABLE
(maphash (lambda (waypt dirpath)
(message "waypt: %s, dirpath: %s" waypt dirpath))
fpln)
;; -------------------------------------------------------
;; ALIST
(dolist (entry fpln)
(let* ( (waypt (car entry))
(dirpath (questorium-fpln-waypt waypt fpln))
(wptfail (cdr (assoc waypt anctr)))
(start (point)) )
;; Insert waypoint
(insert (format " - %-8s" waypt))
;; Apply color based on validity
(add-text-properties start (point)
`(face (:foreground ,(if wptfail "red" "green"))))
;; Insert validity text
(insert (format "\n %s\n" dirpath)))) )
(goto-char (point-min)))
(switch-to-buffer qbuffer)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Avoiding code replication for hash-table,
Heime <=