From 596e7c97a9ff6402da2ca1b54be29c6fc7fdfa86 Mon Sep 17 00:00:00 2001 From: Jakub Darul Date: Wed, 9 Oct 2019 23:21:33 +0200 Subject: [PATCH 1/6] added company-files support for file links in org mode --- modules/completion/company/config.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 9c92a53c0..542b0b333 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -31,7 +31,9 @@ :before #'company-begin-backend (company-abort))) - (add-hook 'company-mode-hook #'+company-init-backends-h) + (add-hook 'company-mode-hook #'(lambda () + (+company-init-backends-h) + (setq company-files--regexps (cons "file\:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)" company-files--regexps)))) (global-company-mode +1)) From 9a79f3815fb373378d12dcadc1ac9435a99f8cab Mon Sep 17 00:00:00 2001 From: Jakub Darul Date: Thu, 10 Oct 2019 10:04:30 +0200 Subject: [PATCH 2/6] moved comapny files regexp for org mode to org/config.el --- modules/completion/company/config.el | 4 +--- modules/lang/org/config.el | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 542b0b333..9c92a53c0 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -31,9 +31,7 @@ :before #'company-begin-backend (company-abort))) - (add-hook 'company-mode-hook #'(lambda () - (+company-init-backends-h) - (setq company-files--regexps (cons "file\:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)" company-files--regexps)))) + (add-hook 'company-mode-hook #'+company-init-backends-h) (global-company-mode +1)) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 7145f203c..afc84200a 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -859,6 +859,14 @@ compelling reason, so..." #'+org-enable-auto-update-cookies-h #'+org-unfold-to-2nd-level-or-point-h) + (if (featurep! :completion company) + (add-hook 'org-mode-hook + #'(lambda () + (require 'company-files) + (setq company-files--regexps (cons "file:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)" + company-files--regexps))))) + + (add-hook! 'org-load-hook #'+org-init-appearance-h #'+org-init-agenda-h From 02decf5a2ef34d97ad2334085381ba1ab7020828 Mon Sep 17 00:00:00 2001 From: Jakub Darul Date: Thu, 10 Oct 2019 20:10:10 +0200 Subject: [PATCH 3/6] made org-company setting regex lazy and removed lambda --- modules/lang/org/config.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index afc84200a..eab2442e6 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -814,6 +814,17 @@ compelling reason, so..." (sp-local-pair "~" "~" :unless '(:add sp-point-before-word-p +org-sp-in-src-block-p)) (sp-local-pair "=" "=" :unless '(:add sp-point-before-word-p sp-in-math-p +org-sp-in-src-block-p))))) +(defun +org-init-company-h() + (after! company + (setq company-files--regexps + (let* ((root (if (eq system-type 'windows-nt) + "[a-zA-Z]:/" + "/")) + (begin (concat "\\(?:\\.\\{1,2\\}/\\|~/\\|" root "\\)"))) + (list (concat "\"\\(" begin "[^\"\n]*\\)") + (concat "\'\\(" begin "[^\'\n]*\\)") + (concat "file:\\(" begin "[^\]\n]*\\)") + (concat "\\(?:[ \t=]\\|^\\)\\(" begin "[^ \t\n]*\\)")))))) ;; ;;; Bootstrap @@ -859,12 +870,6 @@ compelling reason, so..." #'+org-enable-auto-update-cookies-h #'+org-unfold-to-2nd-level-or-point-h) - (if (featurep! :completion company) - (add-hook 'org-mode-hook - #'(lambda () - (require 'company-files) - (setq company-files--regexps (cons "file:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)" - company-files--regexps))))) (add-hook! 'org-load-hook @@ -885,7 +890,8 @@ compelling reason, so..." #'+org-init-popup-rules-h #'+org-init-protocol-h #'+org-init-protocol-lazy-loader-h - #'+org-init-smartparens-h) + #'+org-init-smartparens-h + #'+org-init-company-h) ;; In case the user has eagerly loaded org from their configs (when (and (featurep 'org) From fa14fc96887c0a18e194b0fa272a880750e2da57 Mon Sep 17 00:00:00 2001 From: Jakub Darul Date: Thu, 10 Oct 2019 20:12:58 +0200 Subject: [PATCH 4/6] formatting fix --- modules/lang/org/config.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index eab2442e6..361868680 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -870,8 +870,6 @@ compelling reason, so..." #'+org-enable-auto-update-cookies-h #'+org-unfold-to-2nd-level-or-point-h) - - (add-hook! 'org-load-hook #'+org-init-appearance-h #'+org-init-agenda-h From d3ebe747b64e37f4db1d7a488decaa610ad8d38a Mon Sep 17 00:00:00 2001 From: Jakub Darul Date: Thu, 10 Oct 2019 20:21:35 +0200 Subject: [PATCH 5/6] fix for +org-company-init-h company-files-regexps initialization --- modules/lang/org/config.el | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 361868680..a6fb02244 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -814,18 +814,11 @@ compelling reason, so..." (sp-local-pair "~" "~" :unless '(:add sp-point-before-word-p +org-sp-in-src-block-p)) (sp-local-pair "=" "=" :unless '(:add sp-point-before-word-p sp-in-math-p +org-sp-in-src-block-p))))) -(defun +org-init-company-h() - (after! company - (setq company-files--regexps - (let* ((root (if (eq system-type 'windows-nt) - "[a-zA-Z]:/" - "/")) - (begin (concat "\\(?:\\.\\{1,2\\}/\\|~/\\|" root "\\)"))) - (list (concat "\"\\(" begin "[^\"\n]*\\)") - (concat "\'\\(" begin "[^\'\n]*\\)") - (concat "file:\\(" begin "[^\]\n]*\\)") - (concat "\\(?:[ \t=]\\|^\\)\\(" begin "[^ \t\n]*\\)")))))) - +(defun +org-init-company-h () + (after! company-files + (setq-local company-files--regexps + (cons "file:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)" + company-files--regexps)))) ;; ;;; Bootstrap From d74ed618ce41975c423db4a0b3ef143de4602d4e Mon Sep 17 00:00:00 2001 From: Jakub Darul Date: Thu, 10 Oct 2019 20:34:52 +0200 Subject: [PATCH 6/6] moved company-files-regexps change from org/config to company/conif --- modules/completion/company/config.el | 5 +++++ modules/lang/org/config.el | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 9c92a53c0..2096983d7 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -51,6 +51,11 @@ ;; ;; Packages +(after! company-files + (pushnew! company-files--regexps + "file:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)")) + + (use-package! company-prescient :hook (company-mode . company-prescient-mode) :config diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index a6fb02244..7145f203c 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -814,11 +814,7 @@ compelling reason, so..." (sp-local-pair "~" "~" :unless '(:add sp-point-before-word-p +org-sp-in-src-block-p)) (sp-local-pair "=" "=" :unless '(:add sp-point-before-word-p sp-in-math-p +org-sp-in-src-block-p))))) -(defun +org-init-company-h () - (after! company-files - (setq-local company-files--regexps - (cons "file:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)" - company-files--regexps)))) + ;; ;;; Bootstrap @@ -881,8 +877,7 @@ compelling reason, so..." #'+org-init-popup-rules-h #'+org-init-protocol-h #'+org-init-protocol-lazy-loader-h - #'+org-init-smartparens-h - #'+org-init-company-h) + #'+org-init-smartparens-h) ;; In case the user has eagerly loaded org from their configs (when (and (featurep 'org)