0

This question already has an answer here:

Although these two expressions seems to be equivalent (both works):

;; 1
(highlight-regexp "foo" "hi-green")

;; 2
(highlight-regexp "foo" 'hi-green)

Only the first one of the following loops works appropriately:

;; 1
(defun my-highlights ()
  (interactive)
  (let* ((ALIST  '(("foo" . "hi-green")
                   ("bar" . "hi-yellow"))))
    (dolist (COUPLE LIST)
      (let* ((REGEXP (car COUPLE))
             (HI_FACE (cdr COUPLE)))
        (highlight-regexp REGEXP HI_FACE)))))

;; 2
(defun my-highlights ()
  (interactive)
  (let* ((ALIST  '(("foo" . 'hi-green)
                   ("bar" . 'hi-yellow))))
    (dolist (COUPLE LIST)
      (let* ((REGEXP (car COUPLE))
             (HI_FACE (cdr COUPLE)))
        (highlight-regexp REGEXP HI_FACE)))))

In the second case the cdr of the cons cell is ignored. Why? (I'd like to use the form ("foo" . face).)

marked as duplicate by Drew, Community Feb 23 at 21:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Remove the quote from the cdr in the second version’s alist. Does it work? – Dan Feb 23 at 21:03
  • @Dan It works. Thank you. I was sure I tried to do it. Please, post you comment as an answer so that I can accept it and close this issue. – Gabriele Nicolardi Feb 23 at 21:37

Browse other questions tagged or ask your own question.