Skip to content

Commit

Permalink
Rename debug variable to dir-config--debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescherti committed Aug 18, 2024
1 parent 391b9fe commit 9251e0e
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions dir-config.el
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,6 @@ dir-config loading."
:type 'boolean
:group 'dir-config)

(defcustom dir-config-debug nil
"Enable debug mode for dir-config operations if non-nil.
When this option is enabled, detailed debug information will be logged for
various dir-config activities, including:
- Loading of directory config files
- Cases where directory config files are not found
- Internal state and processing steps
- No error handling
This option is useful for diagnosing and troubleshooting complex issues."
:type 'boolean
:group 'dir-config)

(defcustom dir-config-allowed-directories '()
"List of directory names where dir-config files are allowed.
Both the dir-config file (e.g., '.dir-config.el') and the buffer path must be
Expand All @@ -110,6 +98,16 @@ under these directories, not just the dir-config file."
:group 'dir-config)

;; Internal variables
(defvar dir-config--debug nil
"Internal variable that enables debug mode if non-nil.
When this option is enabled, detailed debug information will be logged for
various dir-config activities, including:
- Loading of directory config files
- Cases where directory config files are not found
- Internal state and processing steps
- No error handling
This option is useful for diagnosing and troubleshooting complex issues.")

(defvar dir-config--loaded nil)
(defvar dir-config--allowed-p nil)
(defvar dir-config--file nil)
Expand Down Expand Up @@ -187,15 +185,15 @@ The dir-config file is loaded only if the directory is allowed and is sourced
from the closest parent directory of the buffer."
(if (bound-and-true-p dir-config--loaded)
;; Skip it
(when dir-config-debug
(when dir-config--debug
(dir-config--message "[DEBUG] %s: Skipping load as already loaded: %s"
(buffer-name)
dir-config--file))
;; Load it
(let ((current-dir (dir-config--buffer-cwd)))
(if (not current-dir)
;; Buffer not supported
(when dir-config-debug
(when dir-config--debug
(dir-config--message (concat "[DEBUG] Ignored because the "
"buffer '%s' is not supported"
" (major-mode: %s)")
Expand All @@ -211,7 +209,7 @@ from the closest parent directory of the buffer."
(dir-config--find-dominating-file dir-config-file-names
current-dir)))
(if (not dir-config-file)
(when dir-config-debug
(when dir-config--debug
(dir-config--message (concat
"[DEBUG] %s: None of the dir-config "
"files %s were found for the '%s' "
Expand All @@ -236,7 +234,7 @@ from the closest parent directory of the buffer."
(setq-local dir-config--file dir-config-file)

;; Load
(if dir-config-debug
(if dir-config--debug
(progn
;; Do not handle errors when debug is activated
(load dir-config-file nil t t)
Expand Down

0 comments on commit 9251e0e

Please sign in to comment.