emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [FR] Don't hardcode checker functions prefix in org-lint


From: Gustavo Barros
Subject: Re: [FR] Don't hardcode checker functions prefix in org-lint
Date: Thu, 12 Nov 2020 22:08:18 -0300
User-agent: mu4e 1.4.13; emacs 27.1

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]