2017-06-22 22 views
2

爲了某種愚蠢的原因,我想寫一個完整的讀取函數來讀取Emacs的縮寫。如何在elisp中找到所有可用的縮寫?

(defun ivy-abbrev (abbrev-name) 
    (interactive 
    (list 
    (ivy-completing-read "Insert abbrev: " (...get abbrev names here...)))) 
    (progn 
    (abbrev-insert (abbrev-symbol abbrev-name ..appropriate abbrev-table...)))) 

遺憾的是沒有任何東西使文檔中......獲得縮寫名稱...看看這樣做,能夠:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Abbrevs.html#Abbrevs

abbrev--before-point展望源,它看起來好像有一個在每次調用時通過abbrev--active-tables進行遞歸搜索。

在這個縮寫API中是否有一個輔助方法可以使這更容易?

+0

'M-x write-abbrev-file'將所有當前定義的縮寫寫入您指定的文件。使用'quietly-read-abbrev-file'或'read-abbrev-file'來讀取它。名稱爲變量'abbrev-file-name'的值的文件默認使用。 – Drew

回答

1

您可以使用類似下面

(cl-loop for table in (abbrev--active-tables) 
    unless (abbrev-table-empty-p table) 
    append (append (delete 0 table)())) 

注意,追加零到向量是一招創建列表。

相關問題