emacs: abbrev-mode can't work in python-mode

ぐ巨炮叔叔 提交于 2019-12-13 06:15:15

问题


I have defined some abbreviations for python mode by using code like this

(define-abbrev-table 'python-mode-abbrev-table
  '(
    ("i_settings" "from django.conf import settings")
    ("i_requestcontext" "from django.template import RequestContext")
    ("i_model" "from django.db import models")
    ("i_form" "from django import forms")
    ))

but it can't work correctly. for example, I input "i_settings" then input a space, emacs doesn't expand to "from django.conf import settings". I have tried it with all configuration disabled, but no help.


回答1:


It seems the underscore _ is preventing the expansion. Try the same table without underscores

(define-abbrev-table 'python-mode-abbrev-table
  '(
    ("isettings" "from django.conf import settings")
    ("irequestcontext" "from django.template import RequestContext")
    ("imodel" "from django.db import models")
    ("iform" "from django import forms")
    ))

and it will work as expected.




回答2:


The internal proceeding expanding an abbrev --abbrev--before-point-- relies on word-syntax - can't see a reason for this BTW, Emacs could take any printable instead.

In result, with any mode where underscore-character has word syntax, your definitions should work - for example with python-mode.el.



来源:https://stackoverflow.com/questions/19875741/emacs-abbrev-mode-cant-work-in-python-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!