Skip to content

Commit

Permalink
fix: improve src file minor mode checking
Browse files Browse the repository at this point in the history
previously would not catch list files which had leading spaces

get-link would just return the path to the root of the repo in case of
error, now the messages are more helpful and actually generates an error
  • Loading branch information
andrewpeck committed Jan 17, 2024
1 parent 36b41b9 commit 5c053a8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions hog.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; hog.el --- Functions for working with Hog -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2021-2023 Andrew Peck
;; Copyright (C) 2021-2024 Andrew Peck

;; Author: Andrew Peck <[email protected]>
;; URL: https://github.com/andrewpeck/hog-emacs
Expand Down Expand Up @@ -423,11 +423,11 @@ The resulting list is of the form:
"Return the link at point in a Hog src file."
(let ((inhibit-message t))
(let ((filename
(progn
(thing-at-point-looking-at hog--file-name-re)
(match-string-no-properties 1))))
(concat (hog--project-root)
filename))))
(progn (thing-at-point-looking-at hog--file-name-re)
(match-string-no-properties 1))))
(if (and filename (not (string-empty-p filename)))
(concat (hog--project-root) filename)
(buffer-substring-no-properties (line-beginning-position) (line-end-position))))))

;; FIXME: does not work with file names with spaces
;; spaces should be escaped
Expand Down Expand Up @@ -665,7 +665,7 @@ template at a specific PATH."
(while (< (line-number-at-pos) (line-number-at-pos (point-max)))

;; skip comments
(when (not (string-match "^\s*#.*"
(when (not (string-match "^#.*"
(buffer-substring-no-properties
(line-beginning-position)
(line-end-position))))
Expand All @@ -674,9 +674,12 @@ template at a specific PATH."
(link-is-glob (file-expand-wildcards link))
(link-exists (file-exists-p link)))

(when (not (or link-exists link-is-glob))
(when (or (not link)
(string-empty-p link)
(not link-exists)
(not link-is-glob))
(setq errors (+ 1 errors))
(princ (format "Error:%d %s not found\n" (line-number-at-pos) link)))))
(princ (format "Error:%d \"%s\" not found\n" (line-number-at-pos) link)))))
(forward-line))) errors))

(provide 'hog)
Expand Down

0 comments on commit 5c053a8

Please sign in to comment.