cc-other-file-alist is part of
find-file that looks something like this.
(("\\.cc\\'" (".hh" ".h")) ("\\.hpp\\'" (".cpp")) ;; more such entries )
This is an alist where I'd like to append an additional entry to the
"\\.hpp\\'". I've done it but I feel it's too round about.
(with-eval-after-load 'find-file (setq my-cc-other-file-alist (copy-alist cc-other-file-alist)) ;; create a new cons (key-value) pair in the alist (add-to-list 'my-cc-other-file-alist '("\\.mm\\'" (".h"))) ;; Add: .h -> .mm, .hpp -> .inl ;; append to existing value (list) for a given key (setcdr (assoc "\\.h\\'" my-cc-other-file-alist) (list (append (car (cdr (assoc "\\.h\\'" my-cc-other-file-alist))) '(".mm")))) (setcdr (assoc "\\.hpp\\'" my-cc-other-file-alist) (list (append (car (cdr (assoc "\\.hpp\\'" my-cc-other-file-alist))) '(".inl")))) (setq-default ff-other-file-alist 'my-cc-other-file-alist))
I'm sure there would be an elegant way to reference the inner list (
cdr) and simply append to it, instead of making copying and replacing. Please tell me there's a better way and show me how!