-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supoprt ghq default direcotry(~/.ghq). #5
Conversation
新しい |
こんな具合にすればよいかと思います. (defun helm-ghq--root ()
(with-temp-buffer
(unless (zerop (process-file "ghq" nil t nil "root"))
(error "Failed: 'ghq root'"))
(goto-char (point-min))
(helm-current-line-contents))) |
|
@syohex いつもありがとうございます!
insertでバッファにかけるんですね。 |
(unless (zerop (call-process "git" nil t nil "config" "ghq.root")) | ||
(error "Failed: Can't find ghq.root")) | ||
(unless (zerop (process-file "ghq" nil t nil "root")) | ||
(error "Failed: 'ghq root'")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
古いバージョンを使っている人はここに来るので、
「ghq root
はverXXから追加された」ことを書けばよいかと思いましたが、
https://github.com/motemen/ghq/releases 見るとリリース版には入ってないのですね。
(ghq root自体は x-motemen/ghq#34 でマージされた)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ああ、"No help topic for 'root'"という文字列が返るのかな。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root
サブコマンドが実装されたバージョンのバイナリがリリースされていない
ことは見落としていました. リリースされるまでは fallbackさせる等する必要が
ありそうです(さすがに go get
でインストールさせるのはやりすぎだと思うので)
PRありがとうございます!ちょっと考えます。 ※ force pushされたようですが、経緯が分からなくなるのであまりオススメしません。 |
@masutaka ご対応ありがとうございます。
元々は~/.ghqのディレクトリの有無を判断して存在した場合にはecho "~/.ghq"しておりました。 |
あと詳しく見ていなかったのですが, |
すべてを考慮するとこんな感じでしょうか. diff --git a/helm-ghq.el b/helm-ghq.el
index d08af0e..c06e23c 100644
--- a/helm-ghq.el
+++ b/helm-ghq.el
@@ -52,12 +52,21 @@
`(buffer-substring-no-properties
(line-beginning-position) (line-end-position)))
+(defun helm-ghq--root-fallback ()
+ (erase-buffer)
+ (unless (zerop (process-file "git" nil t nil "config" "ghq.root"))
+ (error "Failed: Can't find ghq.root"))
+ (goto-char (point-min))
+ (expand-file-name (helm-ghq--line-string)))
+
(defun helm-ghq--root ()
(with-temp-buffer
- (unless (zerop (call-process "git" nil t nil "config" "ghq.root"))
- (error "Failed: Can't find ghq.root"))
+ (process-file "ghq" nil t nil "root")
(goto-char (point-min))
- (expand-file-name (helm-ghq--line-string))))
+ (let ((output (helm-ghq--line-string)))
+ (if (string-match-p "\\`No help topic" output)
+ (helm-ghq--root-fallback)
+ (expand-file-name output)))))
(defun helm-ghq--list-candidates ()
(with-temp-buffer
|
@syohex ありがとうございます。
masutakaさんが宜しければsyohexさんものを追加でコミットしたいと思いますのでそのときは言ってください。 |
はい. |
👍 |
Supoprt ghq default direcotry(~/.ghq).
@sona-tar |
@masutaka マージとメールの件ありがとうございます。 |
Emacs lispをinit.el以外で初めて書いてPRさせて頂きました。
部分的に動作させながらコードを理解して、標準出力させた値を元にrootディレクトリをとってきているところは理解できたのですが、純粋に標準出力だけを実現する方法がわからずcall-processでechoしてしまいました。
(princなどでは文字列が評価されて2回出力されてしまう)
Emacs Lisp で prin1とprincとprintの違い - ながとダイアリー
http://d.hatena.ne.jp/mclh46/20100914/1284465897
その他も含めて問題があれば再度修正後にPRさせて貰いたいと思うのでレビューよろしくお願いします。