Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2007-01-23 08:49:48
Size: 4527
Editor: ZoomQuiet
Comment:
Revision 3 as of 2009-11-28 17:14:10
Size: 4509
Editor: Elias
Comment: 删除对PageComment2组件的引用
Deletions are marked like this. Additions are marked like this.
Line 81: Line 81:
[[PageComment2]]

python-model和这个folding ::-- ZoomQuiet [DateTime(2007-01-23T08:49:48Z)] TableOfContents

Include(CPUGnav)

1. folding for python-model

  • 问一下,python-model和这个folding脚本该怎么安装?(刚开始用emacs) by flyaflya
    • 我用的windows,安装python-mode如下:创建一个 .emacs 文件放到你的 c:/ 下,.emacs内容如下:
      • (setq load-path (cons "c:/emacs/python_mode" load-path))
        (setq auto-mode-alist
              (cons '("\\.py$" . python-mode) auto-mode-alist))
        (setq interpreter-mode-alist
              (cons '("python" . python-mode)
                    interpreter-mode-alist))
        ;;(setq python-mode-hook
        ;;      '(lambda() (progn
        ;;                 (set-variable 'py-indent-offset 4)
        ;;                 (set-variable 'py-smart-indentation nil)
        ;;                 (set-variable 'indent-tabs-mode nil) )))
        (defconst py-python-command "c:/python24/python.exe")
        (autoload 'python-mode "python-mode" "Python editing mode." t)
        ;;---------------------------------------------
        ;; add my customization
        (add-hook 'python-mode-hook 'my-python-hook)
        ;; this gets called by outline to deteremine the level. Just use the length of the whitespace
        (defun py-outline-level ()
          (let (buffer-invisibility-spec)
            (save-excursion
              (skip-chars-forward "\t ")
              (current-column))))
        ;; this get called after python mode is enabled
        (defun my-python-hook ()
          ;; outline uses this regexp to find headers. I match lines with no indent and indented "class"
          ;; and "def" lines.
          (setq outline-regexp "[^ \t]\\|[ \t]*\\(def\\|class\\) ")
          ;; enable our level computation
          (setq outline-level 'py-outline-level)
          ;; do not use their \C-c@ prefix, too hard to type. Note this overides some python mode bindings
          (setq outline-minor-mode-prefix "\C-c")
          ;; turn on outline mode
          (outline-minor-mode t)
          ;; initially hide all but the headers
          (hide-body)
          ;; I use CUA mode on the PC so I rebind these to make the more accessible
          (local-set-key [?\C-\t] 'py-shift-region-right)
          (local-set-key [?\C-\S-\t] 'py-shift-region-left)
          ;; make paren matches visible
          (show-paren-mode 1)
        )
        
        ;;----------------------------------
        (custom-set-variables
          ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
          ;; Your init file should contain only one such instance.
         '(case-fold-search t)
         '(current-language-environment "English")
         '(default-input-method "latin-1-prefix")
         '(global-font-lock-mode t nil (font-lock)))
        (custom-set-faces
          ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
          ;; Your init file should contain only one such instance.
         )
        使用的时候 M-x (alt + x ) ,然后输入 python-mode 就可以启动了。 --瘦青蛙
      • 谢谢瘦青蛙提供配置文件。可是我还没有体会出这么复杂的配置emacs的好处。目前,我是把空格数量当作确定outline级别的依据。不知道py-outline-level什么意思。另外,发现这里有人已经提到了folding,当时,我还以为是outline的一种称呼。现在,我比较重度的使用folding来代替leo。 - tomz
      • python-mode中是不带folding的. 上面那个缩进使用的是Emacs自带的outline-minor-mode. 原帖见: http://groups.google.ca/group/comp.lang.python/browse_thread/thread/43a4d75404cc64fe/956f1c2d37f93995?&hl=en#956f1c2d37f93995 -- ["nickcheng"]

  • 嗯嗯?感觉折叠和Leo的节点还是有区分的,前者是通过预先约定的语法原则,Leo 则是完全的根据需要,不同的理念吧……ZoomQuiet

    • folding不是outline那样根据语法规则来确定折叠。而是能够随意选择一部分来折叠。这样,在emacs中就有了两种折叠方式。一个是随意的折叠,就像leo那样,另外,是根据语法来折叠,这样,就不用象leo那样,每个函数还要再分别定义节点,减少了这个重复工作量。而且,用folding这种方式,就没有leo那样的预处理过程,完全就在python文件中操作。同时和python-mode相结合,能够方便的调试。当然,不像leo这样专门的工具那样友好。所以,我建议还是体会leo的感觉,才能体会到folding到底有多重要。 -tomz
  • folding可以参考: http://wiki.woodpecker.org.cn/moin/Emacs23#head-ebd91b388c6955805dda8ebf4899a3f2d92fa90a -- ["nickcheng"]

2. 反馈

EmaceFold (last edited 2009-12-25 07:09:53 by localhost)