Hi All, This is a small feature request for `org-lint' not to hardcode the checker functions' prefix, as it currently does. `org-lint' is a small gem in Org, specially to those fat-fingered folks such as myself, to the point that it's been some time since I've been fancying using it to check some of my own personal conventions and structures, beyond Org syntax. It is not difficult to do so, and it is enough to define some appropriate checker functions and a personal `my-org-lints' let binding `org-lint--checkers' to my own set of checkers. It's pretty neat. However, `org-lint' hardcodes the prefix of the checker functions to its own prefix, so that to define my own personal checker functions I have to step on `org-lint's namespace, and use "org-lint-" as a prefix, to get things working. The hardcoding occurs in `org-lint--generate-reports', when each checker is called with: #+begin_src emacs-lisp (funcall (intern (format "org-lint-%s" (org-lint-checker-name c))) ast) #+end_src It would be really useful, and simple enough, if a variable was defined, such as: #+begin_src emacs-lisp (defvar org-lint-checker-prefix "org-lint") #+end_src and the call used this variable instead of hardcoding its value: #+begin_src emacs-lisp (funcall (intern (format "%s-%s" org-lint-checker-prefix (org-lint-checker-name c))) ast) #+end_src This would allow to define the mentioned `my-org-lints' function let binding `org-lint--checkers' and `org-lint-checker-prefix' to appropriate values. So that an user's checker functions could have names with other prefixes. As far as my grasp of `org-lint' goes (still learning), that would be enough for users to enjoy its infrastructure for personal lints without having to invade org-lint's namespace. If you think it's a good idea, I'd certainly appreciate it to be included. Thank you. Best regards, Gustavo.
Hi All,
On Tue, 10 Nov 2020 at 17:22, Gustavo Barros <gusbrs.2016@gmail.com>
wrote:
> This is a small feature request for `org-lint' not to hardcode the
> checker
> functions' prefix, as it currently does.
I've been playing with and testing this further, and I found an
uncovered corner in my initial suggestion: the revert-buffer behavior in
the report buffer. It is still simple to handle it, but requires a
couple of extra steps: set the prefix variable as a buffer local
variable in the report buffer in `org-lint--display-reports' and
let-bind this value before moving to the linted buffer in
`org-lint--generate-reports'.
As an extra sugar, but non essential, it would also be nice to be able
to set the report buffer's name.
In sum, the suggestion/request then entails:
#+begin_src emacs-lisp
(defvar-local org-lint--checkers-prefix nil)
(defvar-local org-lint--report-buffer-name nil)
(defun org-lint--generate-reports (buffer checkers)
(let ((checkers-prefix (or org-lint--checkers-prefix "org-lint")))
(with-current-buffer buffer
;; [...]
(funcall
(intern (format "%s-%s"
checkers-prefix
(org-lint-checker-name c)))
ast)
;; [...]
)))
(defun org-lint--display-reports (source checkers)
;; changed let-binding <--
(let ((buffer (get-buffer-create (or org-lint--report-buffer-name
"*Org Lint*"))))
(with-current-buffer buffer
(org-lint--report-mode)
(setf org-lint--source-buffer source)
(setf org-lint--local-checkers checkers)
;; added variable setting <--
(setf org-lint--checkers-prefix org-lint--checkers-prefix)
(org-lint--refresh-reports)
(tabulated-list-print)
(add-hook 'tabulated-list-revert-hook #'org-lint--refresh-reports
nil t))
(pop-to-buffer buffer)))
#+end_src
That's about it. With it, I get a fully functional Lint report for
personal lints with something like:
#+begin_src emacs-lisp
(defun my/org-lint (&optional arg)
(interactive "P")
(let ((org-lint--checkers my/org-lint-checkers)
(org-lint--checkers-prefix "my/org-lint")
(org-lint--report-buffer-name "*My Org Lint*"))
(funcall-interactively 'org-lint arg)))
#+end_src
Best regards,
Gustavo.
Hi All,
On Tue, 10 Nov 2020 at 17:22, Gustavo Barros <gusbrs.2016@gmail.com> wrote:
> This is a small feature request for `org-lint' not to hardcode the
> checker functions' prefix, as it currently does.
>
> [...]
>
> However, `org-lint' hardcodes the prefix of the checker functions to its
> own prefix, so that to define my own personal checker functions I have
> to step on `org-lint's namespace, and use "org-lint-" as a prefix, to
> get things working. The hardcoding occurs in
> `org-lint--generate-reports', when each checker is called with:
I'm trying out the new pretest and I was glad to find out that the
function property for `org-lint-checker` has been exposed in the
`cl-defstruct` at `org-lint.el`.
I have no idea if this request had anything to do with it. But,
regardless, to whoever did it, thank you!
Best regards,
Gustavo.