emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Gustavo Barros <gusbrs.2016@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [FR] Don't hardcode checker functions prefix in org-lint
Date: Thu, 12 Nov 2020 22:08:18 -0300	[thread overview]
Message-ID: <87blg2rrlp.fsf@gmail.com> (raw)
In-Reply-To: <87k0ut7yid.fsf@gmail.com>

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	other threads:[~2020-11-13  1:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 20:22 [FR] Don't hardcode checker functions prefix in org-lint Gustavo Barros
2020-11-13  1:08 ` Gustavo Barros [this message]
2023-04-10 15:25 ` Gustavo Barros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87blg2rrlp.fsf@gmail.com \
    --to=gusbrs.2016@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).