문제

What's the reason by concatenate is not working in my abbreviations file? I would like 'env' to expand to this little chunk of code, and for readability reasons I prefer to separate the string into multiple lines. However, the abbreviation seems to be ignored by Emacs.

(define-abbrev-table 'python-mode-abbrev-table
  '(
    ("env" (concatenate 'string
             "#! /usr/bin/env python\n"
             "\n"
             "from __future__ import division\n"
             "from __future__ import print_function\n"
             "from __future__ import absolute_import\n"
             "from __future__ import unicode_literals\n\n")
       nil 3)
   ))
도움이 되었습니까?

해결책

Expressions are not evaluated inside a quoted list. You can use backquote to selectively evaluate parts of a list structure:

(define-abbrev-table 'python-mode-abbrev-table
  `(
    ("env" ,(concatenate 'string
             "#! /usr/bin/env python\n"
             "\n"
             "from __future__ import division\n"
             "from __future__ import print_function\n"
             "from __future__ import absolute_import\n"
             "from __future__ import unicode_literals\n\n")
       nil 3)
))

Within a backquoted expression, comma indicates the parts that should be evaluated.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top