cpp-auto-include icon indicating copy to clipboard operation
cpp-auto-include copied to clipboard

#include<stack> 这个头文件的处理有一点问题。

Open tacmon opened this issue 6 years ago • 10 comments

tacmon avatar Aug 20 '19 12:08 tacmon

It can't be added effectively.

tacmon avatar Aug 20 '19 12:08 tacmon

Same issue. I'm also having trouble including <stack>

ianyepan avatar May 20 '20 13:05 ianyepan

Add following configuration in your conifguration

(with-eval-after-load 'cpp-auto-include
  (add-to-list 'cpp-auto-include--header-regexp (list "stack" t t "\\bstack\\s-*<")))

Or apply following patch.

diff --git a/cpp-auto-include.el b/cpp-auto-include.el
index 7b11c69..d67e5f1 100644
--- a/cpp-auto-include.el
+++ b/cpp-auto-include.el
@@ -126,7 +126,8 @@
                                  (and (or "fixed" "hex")
                                       symbol-end)))))
     ("string" t t "\\bstring\\b")
-    ("utility" t t "\\b\\(?:pair\\s-*<\\|make_pair\\)")))
+    ("utility" t t "\\b\\(?:pair\\s-*<\\|make_pair\\)")
+    ("stack" t t "\\bstack\\s-*<")))
 
 (defun cpp-auto-include--include-line (header)
   (save-excursion

BTW this package provides very low level features, I suppose it is better to use more smart packages which support auto including header rather than this package.

syohex avatar May 20 '20 13:05 syohex

Thanks for the workaround, it works for me now.

I suppose it is better to use more smart packages which support auto including header rather than this package.

Oh? Is there anything that you'd recommend at the moment?

ianyepan avatar May 20 '20 13:05 ianyepan

Oh? Is there anything that you'd recommend at the moment?

Sorry I don't know and I'm no longer use Emacs. However clangd supports auto include feature so lsp-mode might support it.

syohex avatar May 20 '20 13:05 syohex

@syohex Thanks, I have actually using lsp with clangd. I'll look into it then.

ianyepan avatar May 20 '20 13:05 ianyepan

I have excellent news: Turns out that someone loves this so much that he continues to maintain this project privately, and has now grown over 1500+ lines! https://github.com/elbeno/dotemacs/blob/master/.emacs.d/site-lisp/cpp-auto-include.el @syohex If you wish, you can replace this repo's content with his 'fork', provided that you have access to commit and PR. Preferably after giving credits to the fork maintainer Ben. Anyhow, I have mine set up like this now:

(use-package cpp-auto-include ; Copyright (C) 2015 by Syohei Yoshida / Ben Deane
  :bind (:map c++-mode-map ("C-c i" . cpp-auto-include/ensure-includes-for-file)))

ianyepan avatar May 20 '20 14:05 ianyepan

I have no longer write permission of this repository and I cannot change this repository content.

syohex avatar May 20 '20 14:05 syohex

No problem, I'll open a new issue asking the devs here to consider updating the code.

ianyepan avatar May 20 '20 14:05 ianyepan

It would be create if @elbeno could maintain this officially. Interested?

tarsius avatar May 20 '20 16:05 tarsius