From 56c47fbff81922fae3a41d15a43faa3eefe30e45 Mon Sep 17 00:00:00 2001 From: Kisaragi Hiu Date: Fri, 30 Oct 2020 15:23:53 +0900 Subject: [PATCH] (internal): make sure there are no byte-comp warnings... (#1220) ...about undefined functions or unused lexical variables. Undefined functions: for example, s.el and org-element should be `require`'d when their functions are used. Unused lexical variables: if Org isn't loaded yet, dynamic variables defined in org.el would be treated as lexical and byte-comp would emit this warning. This is especially important in the future as native-comp / gccemacs will optimize away unused lexical variables, and we cannot rely on Org having been implicitly loaded before our modules are compiled. Explicitly stating in our modules that the variables are dynamic prevents that. --- org-roam-db.el | 9 +++++++-- org-roam-graph.el | 3 ++- org-roam-link.el | 4 ++++ org-roam-macs.el | 6 ++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/org-roam-db.el b/org-roam-db.el index cea737d..e09ab42 100644 --- a/org-roam-db.el +++ b/org-roam-db.el @@ -35,14 +35,19 @@ (require 'emacsql) (require 'emacsql-sqlite3) (require 'seq) -(require 'org-macs) -(require 'org-roam-macs) + +(eval-and-compile + (require 'org-roam-macs) + ;; For `org-with-wide-buffer' + (require 'org-macs)) (defvar org-roam-directory) (defvar org-roam-enable-headline-linking) (defvar org-roam-verbose) (defvar org-roam-file-name) +(defvar org-agenda-files) + (declare-function org-roam--org-roam-file-p "org-roam") (declare-function org-roam--extract-titles "org-roam") (declare-function org-roam--extract-ref "org-roam") diff --git a/org-roam-graph.el b/org-roam-graph.el index 5497797..8e4cdf9 100644 --- a/org-roam-graph.el +++ b/org-roam-graph.el @@ -32,7 +32,8 @@ ;;; Code: (require 'xml) ;xml-escape-string (require 's) ;s-truncate, s-replace -(require 'org-roam-macs) +(eval-and-compile + (require 'org-roam-macs)) (require 'org-roam-db) ;;;; Declarations diff --git a/org-roam-link.el b/org-roam-link.el index 4863b50..ee0ae1b 100644 --- a/org-roam-link.el +++ b/org-roam-link.el @@ -36,6 +36,10 @@ (require 'ol) (require 'org-roam-compat) +(require 'org-roam-macs) +(require 'org-roam-db) + +(require 'org-element) (defvar org-roam-completion-ignore-case) (defvar org-roam-directory) diff --git a/org-roam-macs.el b/org-roam-macs.el index 520ca7d..c94603b 100644 --- a/org-roam-macs.el +++ b/org-roam-macs.el @@ -34,9 +34,15 @@ ;;; Code: ;;;; Library Requires (require 'dash) +(require 's) (defvar org-roam-verbose) +;; This is necessary to ensure all dependents on this module see +;; `org-mode-hook' and `org-inhibit-startup' as dynamic variables, +;; regardless of whether Org is loaded before their compilation. +(require 'org) + ;;;; Utility Functions (defun org-roam--list-interleave (lst separator) "Interleaves elements in LST with SEPARATOR."