今天和emacs的ido-mode較勁了

來源:互聯網
上載者:User

 

emacs無疑是最強大的編輯器,最近她又升級到23.2
了,內建了強大的cedet。沒有不升級一下的道理。

 

升級後主要是把.emacs中關於cedet載入的配置關掉即可。但是我日常使用的ido-mode居然出現了問題。

 

因為在做symbian手機應用開發,所以隨大流把所有工程放到了C:/Symbian/Source目錄當中,並且用emacs修改,用abld編譯。fine,一步步編寫越來越多的工程,用helloworldbasic到helloworldplus到multiviews。可以在安裝23.2之後,每次在用c-x c-f開啟C:/Symbian/Source時,都只能看到一個helloworldbasic目錄的補全。沒理由啊,我用cmd看過,用explorer看過,source目錄下子目錄不下20個。

 

我重裝回23.1,問題依舊。試過其它目錄,補全都正常。

難道是.emacs出問題了(用-q啟動正常)。我用二分法試完了.emacs,發現問題依舊。

 

最後懷疑到~/.ido.last檔案上,因為在裡面看到了C:/Symbian/Source的cache。刪之。。

重啟emacs。still malfunction...

 

又亂折騰了一會兒,想起,ido-mode可能會在退出時把cache寫回.ido.last,所以退出emacs,刪.ido.last。終於好了。

 

這個cache功能應該是為了加快ido-mode的提示速度,以前怎麼沒注意到呢。用customize-group看到ido裡面的確有cache,既然有cache,就應該有refresh咯。在補全時鍵入c-l,立馬更新,連刪.ido.last都不必,更簡單。如果不喜歡cache,把它定製為0也可以。

 

在前面“亂折騰”那會兒,還去查看了ido-find-file,心想它是不是有bug。在看ido-find-file,我震驚了。原來這函數這麼強大呀,還支援曆史管理、find尋找、Regex。其中的find尋找(在補全時m-f)非常吸引我,這樣可以瞬間定位多級子目錄中的同名檔案。在windows中試了一下,發現不行。ssh到ubuntu中,可用。。。這回鐵是bug沒錯了。。

 

 

我花了些時間修改了 ido-wide-find-dirs-or-files函數,還把cygwin的windows目錄名相容支援開啟了。哈哈。以後find-file就可以跨越多級目錄補全了。。

P.S:在windows下,find.exe和系統內建的有衝突,所以建議把cygwin版的find複製成cygfind,再把

find-program定製成"cygfind"就好了。

 

;remember to set CYGWIN=nodosfilewarning
(defun ido-wide-find-dirs-or-files (dir file &optional prefix
finddir)
  ;; As ido-run-find-command, but returns a list of cons pairs ("file" .
"dir")
  (let ((filenames
     (split-string
      (shell-command-to-string
         (concat find-program " " ;"cygfind "
           (shell-quote-argument dir)
           " -name "
           (shell-quote-argument
            (concat (if prefix "" "*") file "*"))
           " -type " (if finddir "d" "f") " -print"))))
    filename d f
    res)
    (while filenames
      (message find-program)
      (setq filename (car filenames)
        filenames (cdr filenames))
      (if (and (or (string-match "^/" filename) (string-match "^.:"
filename))
           (file-exists-p filename))
      (setq d (file-name-directory filename)
        f (file-name-nondirectory filename)
        res (cons (cons (if finddir (ido-final-slash f t) f) d) res))))
    res))

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.