auto-completeはやっぱ愛されてるな

どもです。


まずajc-java-completeで返り値の型を表示するためにちょいと調べてた。
んで表示させるための,2013/02/23 (Sat)時点での最新版のpopup.elのdiff。

diff --git a/popup.el b/popup.el
index 7bd3ad8..518972a 100644
--- a/popup.el
+++ b/popup.el
@@ -143,7 +143,9 @@ untouched."
   (loop with tab-width = 4
         for item in list
         for summary = (popup-item-summary item)
-        maximize (string-width (popup-x-to-string item)) into width
+        maximize (string-width (popup-x-to-string
+                                (or (get-text-property 0 'view item)
+                                    item))) into width
         if (stringp summary)
         maximize (+ (string-width summary) 2) into summary-width
         finally return
@@ -436,7 +438,8 @@ usual."
                                 (+ summary-width 2)
                               0))))
          (string (car (popup-substring-by-width string content-width)))
-         (string-width (string-width string))
+         (string-width (string-width (or (get-text-property 0 'view string)
+                                         string)))
          (spacing (max (- popup-width string-width summary-width)
                        (if (> popup-width string-width) 1 0)))
          (truncated-summary
@@ -446,7 +449,7 @@ usual."
       (put-text-property 0 (length truncated-summary)
                          'face summary-face truncated-summary))
     (concat margin-left
-            string
+            (or (get-text-property 0 'view string) string)
             (make-string spacing ? )
             truncated-summary
             symbol


一応表示できるけどpopup.elに手を入れるのはなんか違う気がするので,
確認しただけで元の戻しておいた。
情報源のプロパティにそういう機能が欲しいね。


んで,リポジトリのissuesを眺めていたら色々おもしろいのが見つかった。
やっぱreturn typeを表示してほしいという需要はたくさんありそうだね。
https://github.com/auto-complete/auto-complete/pull/54


あとsourceを切り替えるというようなアイデアもやはり。
https://github.com/auto-complete/auto-complete/pull/198
とか
https://github.com/auto-complete/auto-complete/pull/175


やばい,たのしいかも。


ほいでまた俺しか得しない修正。

(defun my-auto-complete-toggle-source ()
  (interactive)
  (let* ((completing-functions
          (loop for source in ac-sources ;(remove 'ac-source-dictionary ac-sources)
                for candidates-func = (cdr (assoc 'candidates (symbol-value source)))
                for prefix-func = (cdr (assoc 'prefix (symbol-value source)))
                for ac-prefix = (or ac-prefix
                                    (cond
                                     ((stringp prefix-func)
                                      (let ((beg
                                             (save-excursion
                                               (if (re-search-backward prefix-func
                                                                       (line-beginning-position)
                                                                       t)
                                                   (or (match-end 1)
                                                       (match-end 0))
                                                 nil))))
                                        (when beg
                                          (buffer-substring-no-properties
                                           beg (point)))))
                                     ((and (symbolp prefix-func)
                                           (fboundp prefix-func)
                                           (funcall prefix-func))
                                      (buffer-substring-no-properties
                                       (funcall prefix-func)
                                       (point)))
                                     (t
                                      nil)))
                ;; do (message "ac-prefix=%s, source=%s, point=%d, ac-point=%s"
                ;;             ac-prefix (symbol-name source) (point) ac-point)
                when (and candidates-func
                          (symbolp candidates-func)
                          (fboundp candidates-func)
                          (funcall candidates-func))
                collect (intern-soft (replace-regexp-in-string "^ac-source"
                                                               "ac-complete"
                                                               (format "%s" source))))))
    (when completing-functions
      (my-auto-complete-toggle-source-1 completing-functions))))