Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想更改次要模式的行为取决于主要模式。现在我正在写如下。
(defun foo (input) (if (or (eql major-mode 'foo-mode) (eql major-mode 'foo1-mode) (eql major-mode 'foo2-mode)) (myfunc-one input) (myfunc-two input)))
我工作,但我不想写 3 次类似的条件语句。我怎样才能更有效地编写它?
(defun foo (input) (if (memql major-mode '(foo-mode foo1-mode foo2-mode)) (myfunc-one input) (myfunc-two input)))
您通常不想major-mode直接测试。相反,您想使用(derived-mode-p 'foo1-mode 'foo2-mode 'foo3-mode).
major-mode
(derived-mode-p 'foo1-mode 'foo2-mode 'foo3-mode)