universal-ctags / citre

A superior code reading & auto-completion tool with pluggable backends.
GNU General Public License v3.0
320 stars 26 forks source link

new citre's citre-config has some problems. #142

Closed e665107 closed 3 months ago

e665107 commented 1 year ago

Hi

When i cloned the new verison(citre-0.3.1) of citre, emacs(28.2) will be get stuck in restore the desktop-files. Yeah, I have used the desktop-save-mode, i find the memory the emacs used is increasing little by little, But when i comment the citre-config, i becomes ok. Follow is my configuration related to the citre:

(use-package citre :ensure t ;; :defer t :init ;; (require 'citre-config) :config (defun prog-mode-citre-bindings() (local-set-key (kbd "C-c j") 'citre-jump) (local-set-key (kbd "C-c l") 'citre-jump-back) (local-set-key (kbd "C-u v") 'citre-peek) (local-set-key (kbd "C-u g") 'citre-peek-through) (local-set-key (kbd "C-u f") 'citre-peek-chain-forward) (local-set-key (kbd "C-u a") 'citre-peek-chain-backward) (local-set-key (kbd "C-u d") 'citre-peek-next-definition) (local-set-key (kbd "C-u s") 'citre-peek-prev-definition) (local-set-key (kbd "C-u r") 'citre-peek-restore) (local-set-key (kbd "C-u w") 'citre-peek-save-session) (local-set-key (kbd "C-u e") 'citre-peek-load-session) (local-set-key (kbd "C-c i") 'custom-citre-completion-at-point) ) (defun prog-mode-citre-c-bindings() (local-set-key (kbd "C-u v") 'citre-peek) (local-set-key (kbd "C-u g") 'citre-peek-through) (local-set-key (kbd "C-u f") 'citre-peek-chain-forward) (local-set-key (kbd "C-u a") 'citre-peek-chain-backward) (local-set-key (kbd "C-u d") 'citre-peek-next-definition) (local-set-key (kbd "C-u s") 'citre-peek-prev-definition) (local-set-key (kbd "C-u r") 'citre-peek-restore) (local-set-key (kbd "C-u w") 'citre-peek-save-session) (local-set-key (kbd "C-u e") 'citre-peek-load-session) (local-set-key (kbd "C-c i") 'custom-citre-completion-at-point) ) (setq ;; citre-readtags-program "~/.emacs.d/user_bins/ctags/readtags" ;; citre-ctags-program "~/.emacs.d/user_bins/ctags/ctags" ;; citre-gtags-program "~/.emacs.d/user_bins/Gnu_global/bin/gtags" ;; citre-global-program "~/.emacs.d/user_bins/Gnuglobal/bin/global" ;; used for things like displaying paths relatively, see its docstring. ;; citre-project-root-function #'projectile-project-root ;; Set this if you want to always use one location to create a tags file. ;; citre-default-create-tags-file-location 'global-cache ;; See the "Create tags file" section above to know these options ;; citre-use-project-root-when-creating-tags t citre-prompt-language-for-ctags-command t ;; By default, when you open any file, and a tags file can be found for it, ;; citre-mode' is automatically enabled. If you only want this to work for ;; certain modes (likeprog-mode'), set it like this. ;; citre-auto-enable-citre-mode-modes '(prog-mode) ) ;; (setq citre-edit-cmd-buf-default-cmd ;; "ctags ;; -o ;; %TAGSFILE% ;; --kinds-all= ;; --fields= ;; --extras=* ;; --extras=-{qualified} ;; -R ;; ./rtl ;; ") ;; (custom-set-variables ;; '(citre-register-completion-backend '(tags global)) ;; '(citre-register-find-definition-backends '(tags global)) ;; '(citre-register-find-reference-backends '(tags)) ;; '(citre-register-tags-in-buffer-backends '(tags global)) ;; '(citre-auto-enable-citre-mode-backends '(tags global)) ;; ) (defun citre-jump+ () (interactive) (condition-case (citre-jump) (error (call-interactively #'xref-find-definitions)))) (add-hook 'verilog-mode-hook 'prog-mode-citre-bindings) (add-hook 'c-mode-hook 'prog-mode-citre-c-bindings) (add-hook 'c++-mode-hook 'prog-mode-citre-c-bindings) )

AmaiKinono commented 1 year ago

I don't know about desktop-save-mode. How can I experiment it in vanilla Emacs?

masatake commented 1 year ago

The section Saving Emacs Sessions in the info pages of Emacs explains it. https://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Emacs-Sessions.html

e665107 commented 1 year ago

Following is my configuration about the desktop-save-mode.

(desktop-save-mode 1) (savehist-mode 1) (setq savehist-additional-variables '()) (add-to-list 'desktop-globals-to-save '(search-ring)) (add-to-list 'desktop-globals-to-save '(kill-ring))

AmaiKinono commented 1 year ago

I can't reproduce. I used your config, saved the desktop session with several buffers running citre-mode, and I can restore it without any problem. I'm on Emacs 28.2.

The content of citre-config.el has not been changed for a long time, but the definition of citre-auto-enable-citre-mode has changed. That's the only place I suspect to have any problems.

Please set debug-on-quit to non-nil in your init.el, and when Emacs stucks, press C-g, you should see a backtrace. Please paste the backtrace here so we can inspect it more.

e665107 commented 1 year ago

Hi, I catch it Debugger entered--Lisp error: (quit) accept-process-output() citre-get-output-lines(("global" "--print-dbpath")) citre-global--get-output-lines(("--print-dbpath"))

f(compiled-function (dir) #<bytecode 0x4673f74d61a64de>)(nil)

citre-global-dbpath() citre-backend-usable-p(global) citre-auto-enable-citre-mode() run-hooks(find-file-hook) after-find-file(nil nil) find-file-noselect-1(# "d:/Program Files/emacs/.emacs.d/modules/config-fin..." :nowarn nil "d:/Program Files/emacs/.emacs.d/modules/config-fin..." (2814749767117621 1455563624)) find-file-noselect("d:/Program Files/emacs/.emacs.d/modules/config-fin..." :nowarn) desktop-restore-file-buffer("d:/Program Files/emacs/.emacs.d/modules/config-fin..." "config-final.el" nil) desktop-create-buffer(208 "d:/Program Files/emacs/.emacs.d/modules/config-fin..." "config-final.el" emacs-lisp-mode (eldoc-mode override-global-mode yas-minor-mode global-auto-revert-mode openwith-mode projectile-mode which-key-mode helm-mode auto-complete-mode helm-gtags-mode aggressive-indent-mode smartparens-mode) 9868 (1949 nil) nil nil ((buffer-display-time 25482 60274 461437 0) (buffer-file-coding-system . utf-8-dos)) ((mark-ring nil))) load-with-code-conversion("d:/program files/emacs/.emacs.d/.emacs.desktop" "d:/program files/emacs/.emacs.d/.emacs.desktop" t t) load("d:/program files/emacs/.emacs.d/.emacs.desktop" t t t) desktop-read()

f(compiled-function () #<bytecode -0x1fd5d5c584ee8437>)()

run-hooks(after-init-hook delayed-warnings-hook) command-line() normal-top-level()

AmaiKinono commented 1 year ago

It seems your global program is running forever, which shouldn't happen.

When running in a directory without gtags database, global should throw an error immediately:

$ global --print-dbpath
global: GTAGS not found.

citre-global-dbpath, which runs this command internally, should return nil immediately:

(citre-global-dbpath)
;; => nil

When running in a directory with a gtags database, global should print its path immediately:

$ global --print-dbpath
/home/kino/.cache/gtags//home/kino/ctags

citre-global-dbpath should return the path immediately

(citre-global-dbpath)
;; => /home/kino/.cache/gtags//home/kino/ctags

I suspect it's a problem of your global program. Could you try run $ global --print-dbpath in different locations and see if stucks?

e665107 commented 1 year ago

I have choose another directory and run the $ global --print-dbpath, it shows as follow:

h:\test_projects\stm32f103_freertos_test_iar>global --print-dbpath global --print-dbpath h:/test_projects/stm32f103_freertos_test_iar

h:\test_projects\stm32f103_freertos_test_iar>

AmaiKinono commented 1 year ago

That's expected. I mean does it stuck in directories without a gtags database?

AmaiKinono commented 3 months ago

Close due to no further response.