* [PATCH] (CEDET development) Improve the bovinate output buffer
@ 2021-04-01 19:58 Fermin
2021-04-01 22:02 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Fermin @ 2021-04-01 19:58 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 830 bytes --]
There is an essential command when developing a new parser with bovine
that is *bovinate*, this gives all the
buffer information about the tags and helps the developer understand
what information is been change.
The idea of this patch is simple, provide a major mode for the bovinate
buffer base on the emacs-lisp mode,
giving that there are a few similarities in the output, it also add more
information in the buffer name, so
you can have different output buffers at the same time with different names.
The idea in the future is to add more information in the bovinate
buffer, so it can truly serve as a debugger
information buffer.
There is 2 patch attached, one of them is the change of the function and
adding of the major mode, the other one
adds the display behavior, so it can also be automatically displayed.
[-- Attachment #1.2: Type: text/html, Size: 1134 bytes --]
[-- Attachment #2: 0001-Add-bovinate-mode-as-a-major-mode-and-improve-the-bo.patch --]
[-- Type: text/x-patch, Size: 2274 bytes --]
From f8c7ee1791ec6eee1993a9e5449112579e193415 Mon Sep 17 00:00:00 2001
From: Fermin <fmfs@posteo.net>
Date: Thu, 1 Apr 2021 21:31:56 +0200
Subject: [PATCH] Add bovinate-mode as a major mode and improve the bovinate
command
---
lisp/cedet/semantic.el | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index fb443fa4a3..421597fceb 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -335,25 +335,32 @@ Do not set this yourself. Call `semantic-debug'.")
Arguments START and END bound the time being calculated."
(float-time (time-subtract end start)))
+(define-derived-mode bovinate-mode emacs-lisp-mode "Bovinate"
+ "Bovinate buffer major-mode, giving that the list is generated with
+`pp-to-string', the syntax is very similar to a list of Emacs Lisp.
+This major mode helps with the syntax highlight of some of the symbols.")
+
(defun bovinate (&optional clear)
"Parse the current buffer. Show output in a temp buffer.
Optional argument CLEAR will clear the cache before parsing.
If CLEAR is negative, it will do a full reparse, and also display
the output buffer."
(interactive "P")
- (if clear (semantic-clear-toplevel-cache))
- (if (eq clear '-) (setq clear -1))
+ (when clear (semantic-clear-toplevel-cache))
(let* ((start (current-time))
- (out (semantic-fetch-tags)))
- (message "Retrieving tags took %.2f seconds."
- (semantic-elapsed-time start nil))
- (when (or (null clear) (not (listp clear))
- (and (numberp clear) (< 0 clear)))
- (pop-to-buffer "*Parser Output*")
- (require 'pp)
+ (tags (semantic-fetch-tags))
+ (time-elapse (semantic-elapsed-time start nil))
+ (bovinate-buffer
+ (format "*Parser Output from %s buffer*" (buffer-name))))
+ (message "Retrieving tags took %.2f seconds." time-elapse)
+ (unless (get-buffer bovinate-buffer)
+ (setq bovinate-buffer (get-buffer-create bovinate-buffer)))
+ (with-current-buffer bovinate-buffer
(erase-buffer)
- (insert (pp-to-string out))
+ (insert (pp-to-string tags))
+ (bovinate-mode)
(goto-char (point-min)))))
+
\f
;;; Functions of the parser plug-in API
;;
--
2.30.2
[-- Attachment #3: 0001-Add-display-as-a-optional-parameter-for-displaying-t.patch --]
[-- Type: text/x-patch, Size: 2148 bytes --]
From 1c1673283186780e6db007f79d4f8aa864660f79 Mon Sep 17 00:00:00 2001
From: Fermin <fmfs@posteo.net>
Date: Thu, 1 Apr 2021 21:53:16 +0200
Subject: [PATCH] Add display as a optional parameter for displaying the buffer
---
lisp/cedet/semantic.el | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index 421597fceb..256b420688 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -337,21 +337,20 @@ Arguments START and END bound the time being calculated."
(define-derived-mode bovinate-mode emacs-lisp-mode "Bovinate"
"Bovinate buffer major-mode, giving that the list is generated with
-`pp-to-string', the syntax is very similar to a list of Emacs Lisp.
+`pp-to-string', the syntax is very similar to a list in Emacs Lisp.
This major mode helps with the syntax highlight of some of the symbols.")
-(defun bovinate (&optional clear)
- "Parse the current buffer. Show output in a temp buffer.
+(defun bovinate (&optional clear display)
+ "Parse the current buffer. Show output in a `bovinate-mode' buffer.
Optional argument CLEAR will clear the cache before parsing.
-If CLEAR is negative, it will do a full reparse, and also display
-the output buffer."
+If non-nil DISPLAY will display the buffer `pop-to-buffer'."
(interactive "P")
(when clear (semantic-clear-toplevel-cache))
(let* ((start (current-time))
(tags (semantic-fetch-tags))
(time-elapse (semantic-elapsed-time start nil))
(bovinate-buffer
- (format "*Parser Output from %s buffer*" (buffer-name))))
+ (format "*Parser Output from %s*" (buffer-name))))
(message "Retrieving tags took %.2f seconds." time-elapse)
(unless (get-buffer bovinate-buffer)
(setq bovinate-buffer (get-buffer-create bovinate-buffer)))
@@ -359,7 +358,8 @@ the output buffer."
(erase-buffer)
(insert (pp-to-string tags))
(bovinate-mode)
- (goto-char (point-min)))))
+ (goto-char (point-min)))
+ (when display (pop-to-buffer bovinate-buffer))))
\f
;;; Functions of the parser plug-in API
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] (CEDET development) Improve the bovinate output buffer
2021-04-01 19:58 [PATCH] (CEDET development) Improve the bovinate output buffer Fermin
@ 2021-04-01 22:02 ` Stefan Monnier
2021-04-02 17:19 ` Fermin
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2021-04-01 22:02 UTC (permalink / raw)
To: Fermin; +Cc: emacs-devel
> From f8c7ee1791ec6eee1993a9e5449112579e193415 Mon Sep 17 00:00:00 2001
> From: Fermin <fmfs@posteo.net>
> Date: Thu, 1 Apr 2021 21:31:56 +0200
> Subject: [PATCH] Add bovinate-mode as a major mode and improve the bovinate
> command
>
> ---
Could you expand this commit message a bit and clarify on the first line
that this regards some part of semantic? E.g.:
Subject: [PATCH] semantic.el (bovinate): Prettify output
* lisp/cedet/semantic.el (bovinate-mode): New major mode.
(bovinate): ???.
where the `???` should say what kind of improvement is brought by the
patch (like "Give a more meaningful name to the buffer"?).
> +(define-derived-mode bovinate-mode emacs-lisp-mode "Bovinate"
> + "Bovinate buffer major-mode, giving that the list is generated with
> +`pp-to-string', the syntax is very similar to a list of Emacs Lisp.
> +This major mode helps with the syntax highlight of some of the symbols.")
AFAICT this is better served by `lisp-data-mode` than `emacs-lisp-mode`, no?
Also, try to make the first line of docstrings be self-contained.
Maybe you could just use `lisp-data-mode` without bothering to
define a new major mode for it.
> (defun bovinate (&optional clear)
> "Parse the current buffer. Show output in a temp buffer.
> Optional argument CLEAR will clear the cache before parsing.
> If CLEAR is negative, it will do a full reparse, and also display
> the output buffer."
> (interactive "P")
> - (if clear (semantic-clear-toplevel-cache))
> - (if (eq clear '-) (setq clear -1))
> + (when clear (semantic-clear-toplevel-cache))
> (let* ((start (current-time))
> - (out (semantic-fetch-tags)))
> - (message "Retrieving tags took %.2f seconds."
> - (semantic-elapsed-time start nil))
> - (when (or (null clear) (not (listp clear))
> - (and (numberp clear) (< 0 clear)))
> - (pop-to-buffer "*Parser Output*")
> - (require 'pp)
> + (tags (semantic-fetch-tags))
> + (time-elapse (semantic-elapsed-time start nil))
> + (bovinate-buffer
> + (format "*Parser Output from %s buffer*" (buffer-name))))
> + (message "Retrieving tags took %.2f seconds." time-elapse)
> + (unless (get-buffer bovinate-buffer)
> + (setq bovinate-buffer (get-buffer-create bovinate-buffer)))
> + (with-current-buffer bovinate-buffer
I think you can simplify the last three lines to
(with-current-buffer (get-buffer-create bovinate-buffer)
> (erase-buffer)
> - (insert (pp-to-string out))
> + (insert (pp-to-string tags))
> + (bovinate-mode)
> (goto-char (point-min)))))
I don't see where the new code implements the "negative CLEAR" behavior.
Also I don't see in the new code where/when the buffer is displayed.
[ Read on before replying ;-) ]
> From 1c1673283186780e6db007f79d4f8aa864660f79 Mon Sep 17 00:00:00 2001
> From: Fermin <fmfs@posteo.net>
> Date: Thu, 1 Apr 2021 21:53:16 +0200
> Subject: [PATCH] Add display as a optional parameter for displaying the buffer
>
> ---
Similar comment abut the commit message.
> (define-derived-mode bovinate-mode emacs-lisp-mode "Bovinate"
> "Bovinate buffer major-mode, giving that the list is generated with
> -`pp-to-string', the syntax is very similar to a list of Emacs Lisp.
> +`pp-to-string', the syntax is very similar to a list in Emacs Lisp.
> This major mode helps with the syntax highlight of some of the symbols.")
This would better be folded into the previous patch.
> -(defun bovinate (&optional clear)
> - "Parse the current buffer. Show output in a temp buffer.
> +(defun bovinate (&optional clear display)
> + "Parse the current buffer. Show output in a `bovinate-mode' buffer.
> Optional argument CLEAR will clear the cache before parsing.
> -If CLEAR is negative, it will do a full reparse, and also display
> -the output buffer."
> +If non-nil DISPLAY will display the buffer `pop-to-buffer'."
> (interactive "P")
This means that when used interactively DISPLAY will always be nil and
hence the buffer will never be "popped". This contradicts the
first line's "Show output in a `bovinate-mode' buffer" and I also wonder
what is the benefit (is it often useful/necessary to do
`M-x bovinate` without wanting to see the resulting tags)?
> (when clear (semantic-clear-toplevel-cache))
> (let* ((start (current-time))
> (tags (semantic-fetch-tags))
> (time-elapse (semantic-elapsed-time start nil))
> (bovinate-buffer
> - (format "*Parser Output from %s buffer*" (buffer-name))))
> + (format "*Parser Output from %s*" (buffer-name))))
This should also be folded into the previous patch.
> (message "Retrieving tags took %.2f seconds." time-elapse)
> (unless (get-buffer bovinate-buffer)
> (setq bovinate-buffer (get-buffer-create bovinate-buffer)))
> @@ -359,7 +358,8 @@ the output buffer."
> (erase-buffer)
> (insert (pp-to-string tags))
> (bovinate-mode)
> - (goto-char (point-min)))))
> + (goto-char (point-min)))
> + (when display (pop-to-buffer bovinate-buffer))))
Hmm... overall, I think the two patches should be squashed together.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] (CEDET development) Improve the bovinate output buffer
2021-04-01 22:02 ` Stefan Monnier
@ 2021-04-02 17:19 ` Fermin
0 siblings, 0 replies; 3+ messages in thread
From: Fermin @ 2021-04-02 17:19 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 6385 bytes --]
Thanks for the feedback!
> AFAICT this is better served by `lisp-data-mode` than `emacs-lisp-mode`, no?
> Also, try to make the first line of docstrings be self-contained.
> Maybe you could just use `lisp-data-mode` without bothering to
> define a new major mode for it.
I couldn't find the lisp-data-mod because I'm developing in the Emacs
27.1 , I did have to change my configuration
so now I can use the build from master.
The idea of the major mode is that I want to add some interactive
behavior, e.g improve the tag navigation with buttons
, so a new major mode can help in that task.
I did change the function from defun to cl-defun, so I can set the
default value of display to true, the idea of non displaying the
source code file is for testing mainly.
> This would better be folded into the previous patch.
Done, I think I address most of the issues, sorry for the inconvenience,
I'm not use to work with mailing list development.
I attach a patch with the changes.
Regards
On 02/04/2021 00:02, Stefan Monnier wrote:
>> From f8c7ee1791ec6eee1993a9e5449112579e193415 Mon Sep 17 00:00:00 2001
>> From: Fermin <fmfs@posteo.net>
>> Date: Thu, 1 Apr 2021 21:31:56 +0200
>> Subject: [PATCH] Add bovinate-mode as a major mode and improve the bovinate
>> command
>>
>> ---
> Could you expand this commit message a bit and clarify on the first line
> that this regards some part of semantic? E.g.:
>
> Subject: [PATCH] semantic.el (bovinate): Prettify output
>
> * lisp/cedet/semantic.el (bovinate-mode): New major mode.
> (bovinate): ???.
>
> where the `???` should say what kind of improvement is brought by the
> patch (like "Give a more meaningful name to the buffer"?).
>
>> +(define-derived-mode bovinate-mode emacs-lisp-mode "Bovinate"
>> + "Bovinate buffer major-mode, giving that the list is generated with
>> +`pp-to-string', the syntax is very similar to a list of Emacs Lisp.
>> +This major mode helps with the syntax highlight of some of the symbols.")
> AFAICT this is better served by `lisp-data-mode` than `emacs-lisp-mode`, no?
> Also, try to make the first line of docstrings be self-contained.
> Maybe you could just use `lisp-data-mode` without bothering to
> define a new major mode for it.
>
>> (defun bovinate (&optional clear)
>> "Parse the current buffer. Show output in a temp buffer.
>> Optional argument CLEAR will clear the cache before parsing.
>> If CLEAR is negative, it will do a full reparse, and also display
>> the output buffer."
>> (interactive "P")
>> - (if clear (semantic-clear-toplevel-cache))
>> - (if (eq clear '-) (setq clear -1))
>> + (when clear (semantic-clear-toplevel-cache))
>> (let* ((start (current-time))
>> - (out (semantic-fetch-tags)))
>> - (message "Retrieving tags took %.2f seconds."
>> - (semantic-elapsed-time start nil))
>> - (when (or (null clear) (not (listp clear))
>> - (and (numberp clear) (< 0 clear)))
>> - (pop-to-buffer "*Parser Output*")
>> - (require 'pp)
>> + (tags (semantic-fetch-tags))
>> + (time-elapse (semantic-elapsed-time start nil))
>> + (bovinate-buffer
>> + (format "*Parser Output from %s buffer*" (buffer-name))))
>> + (message "Retrieving tags took %.2f seconds." time-elapse)
>> + (unless (get-buffer bovinate-buffer)
>> + (setq bovinate-buffer (get-buffer-create bovinate-buffer)))
>> + (with-current-buffer bovinate-buffer
> I think you can simplify the last three lines to
>
> (with-current-buffer (get-buffer-create bovinate-buffer)
>
>> (erase-buffer)
>> - (insert (pp-to-string out))
>> + (insert (pp-to-string tags))
>> + (bovinate-mode)
>> (goto-char (point-min)))))
> I don't see where the new code implements the "negative CLEAR" behavior.
> Also I don't see in the new code where/when the buffer is displayed.
> [ Read on before replying ;-) ]
>
>> From 1c1673283186780e6db007f79d4f8aa864660f79 Mon Sep 17 00:00:00 2001
>> From: Fermin <fmfs@posteo.net>
>> Date: Thu, 1 Apr 2021 21:53:16 +0200
>> Subject: [PATCH] Add display as a optional parameter for displaying the buffer
>>
>> ---
> Similar comment abut the commit message.
>
>> (define-derived-mode bovinate-mode emacs-lisp-mode "Bovinate"
>> "Bovinate buffer major-mode, giving that the list is generated with
>> -`pp-to-string', the syntax is very similar to a list of Emacs Lisp.
>> +`pp-to-string', the syntax is very similar to a list in Emacs Lisp.
>> This major mode helps with the syntax highlight of some of the symbols.")
> This would better be folded into the previous patch.
>
>> -(defun bovinate (&optional clear)
>> - "Parse the current buffer. Show output in a temp buffer.
>> +(defun bovinate (&optional clear display)
>> + "Parse the current buffer. Show output in a `bovinate-mode' buffer.
>> Optional argument CLEAR will clear the cache before parsing.
>> -If CLEAR is negative, it will do a full reparse, and also display
>> -the output buffer."
>> +If non-nil DISPLAY will display the buffer `pop-to-buffer'."
>> (interactive "P")
> This means that when used interactively DISPLAY will always be nil and
> hence the buffer will never be "popped". This contradicts the
> first line's "Show output in a `bovinate-mode' buffer" and I also wonder
> what is the benefit (is it often useful/necessary to do
> `M-x bovinate` without wanting to see the resulting tags)?
>
>> (when clear (semantic-clear-toplevel-cache))
>> (let* ((start (current-time))
>> (tags (semantic-fetch-tags))
>> (time-elapse (semantic-elapsed-time start nil))
>> (bovinate-buffer
>> - (format "*Parser Output from %s buffer*" (buffer-name))))
>> + (format "*Parser Output from %s*" (buffer-name))))
> This should also be folded into the previous patch.
>
>> (message "Retrieving tags took %.2f seconds." time-elapse)
>> (unless (get-buffer bovinate-buffer)
>> (setq bovinate-buffer (get-buffer-create bovinate-buffer)))
>> @@ -359,7 +358,8 @@ the output buffer."
>> (erase-buffer)
>> (insert (pp-to-string tags))
>> (bovinate-mode)
>> - (goto-char (point-min)))))
>> + (goto-char (point-min)))
>> + (when display (pop-to-buffer bovinate-buffer))))
> Hmm... overall, I think the two patches should be squashed together.
>
>
> Stefan
>
[-- Attachment #2: bovinate.patch --]
[-- Type: text/x-patch, Size: 1857 bytes --]
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index fb443fa4a3..a017caa7ff 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -335,25 +335,28 @@ semantic-elapsed-time
Arguments START and END bound the time being calculated."
(float-time (time-subtract end start)))
-(defun bovinate (&optional clear)
+(define-derived-mode bovinate-mode lisp-data-mode "Bovinate"
+ "Bovinate buffer major-mode.")
+
+(cl-defun bovinate (&optional clear (display t))
"Parse the current buffer. Show output in a temp buffer.
-Optional argument CLEAR will clear the cache before parsing.
-If CLEAR is negative, it will do a full reparse, and also display
-the output buffer."
+If CLEAR is non-nil, it will do a full reparse.
+If DISPLAY is nil, it doesn't show the parser buffer."
(interactive "P")
- (if clear (semantic-clear-toplevel-cache))
- (if (eq clear '-) (setq clear -1))
+ (when clear (semantic-clear-toplevel-cache))
(let* ((start (current-time))
- (out (semantic-fetch-tags)))
- (message "Retrieving tags took %.2f seconds."
- (semantic-elapsed-time start nil))
- (when (or (null clear) (not (listp clear))
- (and (numberp clear) (< 0 clear)))
- (pop-to-buffer "*Parser Output*")
- (require 'pp)
+ (tags (semantic-fetch-tags))
+ (time-elapse (semantic-elapsed-time start nil))
+ (bovinate-buffer
+ (format "*Parser Output from %s*" (buffer-name))))
+ (message "Retrieving tags took %.2f seconds." time-elapse)
+ (with-current-buffer (get-buffer-create bovinate-buffer)
(erase-buffer)
- (insert (pp-to-string out))
- (goto-char (point-min)))))
+ (insert (pp-to-string tags))
+ (bovinate-mode)
+ (goto-char (point-min)))
+ (when display (pop-to-buffer bovinate-buffer))))
+
\f
;;; Functions of the parser plug-in API
;;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-02 17:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-01 19:58 [PATCH] (CEDET development) Improve the bovinate output buffer Fermin
2021-04-01 22:02 ` Stefan Monnier
2021-04-02 17:19 ` Fermin
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.