all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
@ 2021-06-19 13:57 Hongyi Zhao
  2021-06-19 14:48 ` Omar Polo
  0 siblings, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-06-19 13:57 UTC (permalink / raw)
  To: help-gnu-emacs

Dear all,

Are there any built-in method of Emacs which can let me conveniently
check/inspect/retrieve the definition/usage of any
commands/symbols/operators used in elisp code at-the-point/in-situ?
Say, for the following code snippets:

;;;
  (defun fk/company-wordfreq-toggle-language (&optional language)
    (interactive)
    (setq ispell-local-dictionary (or language
                                      (if (string=
ispell-local-dictionary "english")
                                          "turkish"
                                        "english")))
[...]
  `(progn
    ,@(mapcar (lambda (p) `(use-package ,p))
              packages)))

(use-multiple-packages flycheck
                       dash
                       )

[...]
(mapcar #'straight-use-package '(flycheck lsp-mode dash ...))

;or equivalently

(defvar my-package-list '(flycheck lsp-mode dash ...))
(mapcar #'straight-use-package my-package-list)
;;;

I want to find some convenient methods built in Emacs itself with an
in-situ manner - by moving the point to the interest position - to
check any commands/symbols/operators used in them.

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
  2021-06-19 13:57 The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code Hongyi Zhao
@ 2021-06-19 14:48 ` Omar Polo
  2021-06-19 15:40   ` Hongyi Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Omar Polo @ 2021-06-19 14:48 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs


Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> Dear all,
>
> Are there any built-in method of Emacs which can let me conveniently
> check/inspect/retrieve the definition/usage of any
> commands/symbols/operators used in elisp code at-the-point/in-situ?
> Say, for the following code snippets:
>
> ;;;
>   (defun fk/company-wordfreq-toggle-language (&optional language)
>     (interactive)
>     (setq ispell-local-dictionary (or language
>                                       (if (string=
> ispell-local-dictionary "english")
>                                           "turkish"
>                                         "english")))
> [...]
>   `(progn
>     ,@(mapcar (lambda (p) `(use-package ,p))
>               packages)))
>
> (use-multiple-packages flycheck
>                        dash
>                        )
>
> [...]
> (mapcar #'straight-use-package '(flycheck lsp-mode dash ...))
>
> ;or equivalently
>
> (defvar my-package-list '(flycheck lsp-mode dash ...))
> (mapcar #'straight-use-package my-package-list)
> ;;;
>
> I want to find some convenient methods built in Emacs itself with an
> in-situ manner - by moving the point to the interest position - to
> check any commands/symbols/operators used in them.
>
> Regards

there is M-. (xref-find-definitions) that will jump to the definition of
the symbol at point (at least in emacs lisp buffers), and M-,
(xref-pop-marker-stack) to jump back.

Or you can C-h f or C-h v (describe-function/variable) and then M-n
(next-history-element) to bring in the symbol at point.



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
  2021-06-19 14:48 ` Omar Polo
@ 2021-06-19 15:40   ` Hongyi Zhao
  2021-06-19 15:57     ` Omar Polo
  0 siblings, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-06-19 15:40 UTC (permalink / raw)
  To: Omar Polo; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]

On Sat, Jun 19, 2021 at 10:48 PM Omar Polo <op@omarpolo.com> wrote:
>
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > Dear all,
> >
> > Are there any built-in method of Emacs which can let me conveniently
> > check/inspect/retrieve the definition/usage of any
> > commands/symbols/operators used in elisp code at-the-point/in-situ?
> > Say, for the following code snippets:
> >
> > ;;;
> >   (defun fk/company-wordfreq-toggle-language (&optional language)
> >     (interactive)
> >     (setq ispell-local-dictionary (or language
> >                                       (if (string=
> > ispell-local-dictionary "english")
> >                                           "turkish"
> >                                         "english")))
> > [...]
> >   `(progn
> >     ,@(mapcar (lambda (p) `(use-package ,p))
> >               packages)))
> >
> > (use-multiple-packages flycheck
> >                        dash
> >                        )
> >
> > [...]
> > (mapcar #'straight-use-package '(flycheck lsp-mode dash ...))
> >
> > ;or equivalently
> >
> > (defvar my-package-list '(flycheck lsp-mode dash ...))
> > (mapcar #'straight-use-package my-package-list)
> > ;;;
> >
> > I want to find some convenient methods built in Emacs itself with an
> > in-situ manner - by moving the point to the interest position - to
> > check any commands/symbols/operators used in them.
> >
> > Regards
>
> there is M-. (xref-find-definitions) that will jump to the definition of
> the symbol at point (at least in emacs lisp buffers),

Thank you very much. But still there are some symbols can't find with
this method, say, #'  ,@  ' and so on.

> and M-, (xref-pop-marker-stack) to jump back.

I use scratch buffer to test, and it can't jump back there.

>
> Or you can C-h f or C-h v (describe-function/variable) and then M-n
> (next-history-element) to bring in the symbol at point.

I meet the following message: M-n is undefined, as shown in the
attached screenshot file.

HY
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China

[-- Attachment #2: 2021-06-19_23-33.png --]
[-- Type: image/png, Size: 87514 bytes --]

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
  2021-06-19 15:40   ` Hongyi Zhao
@ 2021-06-19 15:57     ` Omar Polo
  2021-06-19 17:09       ` Hongyi Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Omar Polo @ 2021-06-19 15:57 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs


Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> On Sat, Jun 19, 2021 at 10:48 PM Omar Polo <op@omarpolo.com> wrote:
>>
>>
>> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>>
>> > Dear all,
>> >
>> > Are there any built-in method of Emacs which can let me conveniently
>> > check/inspect/retrieve the definition/usage of any
>> > commands/symbols/operators used in elisp code at-the-point/in-situ?
>> > Say, for the following code snippets:
>> >
>> > ;;;
>> >   (defun fk/company-wordfreq-toggle-language (&optional language)
>> >     (interactive)
>> >     (setq ispell-local-dictionary (or language
>> >                                       (if (string=
>> > ispell-local-dictionary "english")
>> >                                           "turkish"
>> >                                         "english")))
>> > [...]
>> >   `(progn
>> >     ,@(mapcar (lambda (p) `(use-package ,p))
>> >               packages)))
>> >
>> > (use-multiple-packages flycheck
>> >                        dash
>> >                        )
>> >
>> > [...]
>> > (mapcar #'straight-use-package '(flycheck lsp-mode dash ...))
>> >
>> > ;or equivalently
>> >
>> > (defvar my-package-list '(flycheck lsp-mode dash ...))
>> > (mapcar #'straight-use-package my-package-list)
>> > ;;;
>> >
>> > I want to find some convenient methods built in Emacs itself with an
>> > in-situ manner - by moving the point to the interest position - to
>> > check any commands/symbols/operators used in them.
>> >
>> > Regards
>>
>> there is M-. (xref-find-definitions) that will jump to the definition of
>> the symbol at point (at least in emacs lisp buffers),
>
> Thank you very much. But still there are some symbols can't find with
> this method, say, #'  ,@  ' and so on.

#' ' ` , and ,@ aren't symbols, they are reader macros, i.e. special
character sequences that the lisp reader expands into some special
constructs.  For instance, #'foo is the same as (function 'foo) and 'foo
the same as (quote foo).

If you M-. with the point over quote (in an elisp buffer) it should jump
to eval.c (assuming you have the C source files available).

>> and M-, (xref-pop-marker-stack) to jump back.
>
> I use scratch buffer to test, and it can't jump back there.

M-, is meant to be used after one or more M-.

For instance:

1. in *scratch* type describe-function
2. press M-. -- it'll jump to help-fns.el.gz
3. move the point over with-help-window (something like ~10 lines below)
4. M-. again -- it'll jump to a different place in the same file
5. go back with M-, -- now you're back in the definition of
   describe-function
6. M-, again -- now you're back in the *scratch* buffer

>>
>> Or you can C-h f or C-h v (describe-function/variable) and then M-n
>> (next-history-element) to bring in the symbol at point.
>
> I meet the following message: M-n is undefined, as shown in the
> attached screenshot file.

M-n should be defined in some minibuffer maps; with `emacs -Q' I can

	C-h v C-h k M-n

and it tells me that.

> M-n runs the command next-history-element (found in
> minibuffer-local-must-match-map), which is an interactive compiled
> Lisp function in ‘simple.el’.

Cheers,

> HY




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
  2021-06-19 15:57     ` Omar Polo
@ 2021-06-19 17:09       ` Hongyi Zhao
  2021-06-23  7:48         ` Omar Polo
  0 siblings, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-06-19 17:09 UTC (permalink / raw)
  To: Omar Polo; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 4537 bytes --]

On Sat, Jun 19, 2021 at 11:57 PM Omar Polo <op@omarpolo.com> wrote:
>
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > On Sat, Jun 19, 2021 at 10:48 PM Omar Polo <op@omarpolo.com> wrote:
> >>
> >>
> >> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> >>
> >> > Dear all,
> >> >
> >> > Are there any built-in method of Emacs which can let me conveniently
> >> > check/inspect/retrieve the definition/usage of any
> >> > commands/symbols/operators used in elisp code at-the-point/in-situ?
> >> > Say, for the following code snippets:
> >> >
> >> > ;;;
> >> >   (defun fk/company-wordfreq-toggle-language (&optional language)
> >> >     (interactive)
> >> >     (setq ispell-local-dictionary (or language
> >> >                                       (if (string=
> >> > ispell-local-dictionary "english")
> >> >                                           "turkish"
> >> >                                         "english")))
> >> > [...]
> >> >   `(progn
> >> >     ,@(mapcar (lambda (p) `(use-package ,p))
> >> >               packages)))
> >> >
> >> > (use-multiple-packages flycheck
> >> >                        dash
> >> >                        )
> >> >
> >> > [...]
> >> > (mapcar #'straight-use-package '(flycheck lsp-mode dash ...))
> >> >
> >> > ;or equivalently
> >> >
> >> > (defvar my-package-list '(flycheck lsp-mode dash ...))
> >> > (mapcar #'straight-use-package my-package-list)
> >> > ;;;
> >> >
> >> > I want to find some convenient methods built in Emacs itself with an
> >> > in-situ manner - by moving the point to the interest position - to
> >> > check any commands/symbols/operators used in them.
> >> >
> >> > Regards
> >>
> >> there is M-. (xref-find-definitions) that will jump to the definition of
> >> the symbol at point (at least in emacs lisp buffers),
> >
> > Thank you very much. But still there are some symbols can't find with
> > this method, say, #'  ,@  ' and so on.
>
> #' ' ` , and ,@ aren't symbols, they are reader macros, i.e. special
> character sequences that the lisp reader expands into some special
> constructs.  For instance, #'foo is the same as (function 'foo) and 'foo
> the same as (quote foo).
>
> If you M-. with the point over quote (in an elisp buffer) it should jump
> to eval.c (assuming you have the C source files available).
>
> >> and M-, (xref-pop-marker-stack) to jump back.
> >
> > I use scratch buffer to test, and it can't jump back there.
>
> M-, is meant to be used after one or more M-.
>
> For instance:
>
> 1. in *scratch* type describe-function
> 2. press M-. -- it'll jump to help-fns.el.gz
> 3. move the point over with-help-window (something like ~10 lines below)
> 4. M-. again -- it'll jump to a different place in the same file
> 5. go back with M-, -- now you're back in the definition of
>    describe-function
> 6. M-, again -- now you're back in the *scratch* buffer

Wonderful explanations. But I still failed to reproduce the M-, , as
for the other steps you told above except the last two, I can
reproduce them exactly the same as you described.

See the attachment for the info I saw on the bottom mini-buffer when
hitting M-, (M- comma).

>
> >>
> >> Or you can C-h f or C-h v (describe-function/variable) and then M-n
> >> (next-history-element) to bring in the symbol at point.
> >
> > I meet the following message: M-n is undefined, as shown in the
> > attached screenshot file.
>
> M-n should be defined in some minibuffer maps; with `emacs -Q' I can
>
>         C-h v C-h k M-n
>
> and it tells me that.

I got the following with your above command sequence:

M-n runs the command next-history-element (found in
minibuffer-local-must-match-map), which is an interactive compiled
Lisp function in ‘simple.el’.

It is bound to <XF86Forward>, <next>, M-n, <menu-bar> <minibuf>
<next>.

(next-history-element N)

Puts next element of the minibuffer history in the minibuffer.
With argument N, it uses the Nth following element.  The position
in the history can go beyond the current position and invoke "future
history."

HY

>
> > M-n runs the command next-history-element (found in
> > minibuffer-local-must-match-map), which is an interactive compiled
> > Lisp function in ‘simple.el’.
>
> Cheers,
>
> > HY
>


-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China

[-- Attachment #2: 2021-06-20_01-05.png --]
[-- Type: image/png, Size: 228007 bytes --]

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
  2021-06-19 17:09       ` Hongyi Zhao
@ 2021-06-23  7:48         ` Omar Polo
  2021-06-23  8:56           ` Hongyi Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Omar Polo @ 2021-06-23  7:48 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

(sorry for the delay)

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> On Sat, Jun 19, 2021 at 11:57 PM Omar Polo <op@omarpolo.com> wrote:
>>
>>
>> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>>
>> > On Sat, Jun 19, 2021 at 10:48 PM Omar Polo <op@omarpolo.com> wrote:
>> >>
>> >>
>> >> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>> >>
>> >> > Dear all,
>> >> >
>> >> > Are there any built-in method of Emacs which can let me conveniently
>> >> > check/inspect/retrieve the definition/usage of any
>> >> > commands/symbols/operators used in elisp code at-the-point/in-situ?
>> >> > Say, for the following code snippets:
>> >> >
>> >> > ;;;
>> >> >   (defun fk/company-wordfreq-toggle-language (&optional language)
>> >> >     (interactive)
>> >> >     (setq ispell-local-dictionary (or language
>> >> >                                       (if (string=
>> >> > ispell-local-dictionary "english")
>> >> >                                           "turkish"
>> >> >                                         "english")))
>> >> > [...]
>> >> >   `(progn
>> >> >     ,@(mapcar (lambda (p) `(use-package ,p))
>> >> >               packages)))
>> >> >
>> >> > (use-multiple-packages flycheck
>> >> >                        dash
>> >> >                        )
>> >> >
>> >> > [...]
>> >> > (mapcar #'straight-use-package '(flycheck lsp-mode dash ...))
>> >> >
>> >> > ;or equivalently
>> >> >
>> >> > (defvar my-package-list '(flycheck lsp-mode dash ...))
>> >> > (mapcar #'straight-use-package my-package-list)
>> >> > ;;;
>> >> >
>> >> > I want to find some convenient methods built in Emacs itself with an
>> >> > in-situ manner - by moving the point to the interest position - to
>> >> > check any commands/symbols/operators used in them.
>> >> >
>> >> > Regards
>> >>
>> >> there is M-. (xref-find-definitions) that will jump to the definition of
>> >> the symbol at point (at least in emacs lisp buffers),
>> >
>> > Thank you very much. But still there are some symbols can't find with
>> > this method, say, #'  ,@  ' and so on.
>>
>> #' ' ` , and ,@ aren't symbols, they are reader macros, i.e. special
>> character sequences that the lisp reader expands into some special
>> constructs.  For instance, #'foo is the same as (function 'foo) and 'foo
>> the same as (quote foo).
>>
>> If you M-. with the point over quote (in an elisp buffer) it should jump
>> to eval.c (assuming you have the C source files available).
>>
>> >> and M-, (xref-pop-marker-stack) to jump back.
>> >
>> > I use scratch buffer to test, and it can't jump back there.
>>
>> M-, is meant to be used after one or more M-.
>>
>> For instance:
>>
>> 1. in *scratch* type describe-function
>> 2. press M-. -- it'll jump to help-fns.el.gz
>> 3. move the point over with-help-window (something like ~10 lines below)
>> 4. M-. again -- it'll jump to a different place in the same file
>> 5. go back with M-, -- now you're back in the definition of
>>    describe-function
>> 6. M-, again -- now you're back in the *scratch* buffer
>
> Wonderful explanations. But I still failed to reproduce the M-, , as
> for the other steps you told above except the last two, I can
> reproduce them exactly the same as you described.
>
> See the attachment for the info I saw on the bottom mini-buffer when
> hitting M-, (M- comma).

don't want to sound rude, but could you please refrain from attaching a
whole screenshot just for an error message?  Copying the error, like:

"it says that: buffer is read-only"

it's enough IMHO.  (you'll find a copy of the error message in the
*Messages* buffer if you don't want to type it by hand.)

Now, usually that error is signaled when you try to insert something
into a buffer that read-only.  There can be multiple reasons for that,
but unfortunately I thinks it's something on your end, since I cannot
reproduce with `emacs -Q'.  Make sure that you are hitting M-, and not
the comma alone, or ensure that M-, is bound to xref-pop-marker-stack
and not to something else (C-h k M-,)

As en extreme solution, try to enable the debug-on-error (M-x
toggle-debug-on-error RET) and look at the stacktrace when that error
happens.  (You can use toggle-debug-on-error again to disable it later)

>>
>> >>
>> >> Or you can C-h f or C-h v (describe-function/variable) and then M-n
>> >> (next-history-element) to bring in the symbol at point.
>> >
>> > I meet the following message: M-n is undefined, as shown in the
>> > attached screenshot file.
>>
>> M-n should be defined in some minibuffer maps; with `emacs -Q' I can
>>
>>         C-h v C-h k M-n
>>
>> and it tells me that.
>
> I got the following with your above command sequence:
>
> M-n runs the command next-history-element (found in
> minibuffer-local-must-match-map), which is an interactive compiled
> Lisp function in ‘simple.el’.
>
> It is bound to <XF86Forward>, <next>, M-n, <menu-bar> <minibuf>
> <next>.
>
> (next-history-element N)
>
> Puts next element of the minibuffer history in the minibuffer.
> With argument N, it uses the Nth following element.  The position
> in the history can go beyond the current position and invoke "future
> history."

Yep.  Sorry for giving a long command sequence without any explanation.
`C-h v' is describe-variable, it should enter the minibuffer asking for
a variable to be described.  Then `C-h k' is describe-key, that works in
the minibuffer too.  M-n is bound to next-history-element there too, so
it should work.  When you are over (or at the beginning) of a symbol,
M-n should pull that symbol into the minibuffer.  So with the cursor
over

	toggle-debug-on-error

if I type `C-h f' (describe-function) and then M-n, Emacs automatically
inserts "toggle-debug-on-error" as input in the minibuffer.  Then I can
simply RET to read the documentation of the function :)

> HY
>
>>
>> > M-n runs the command next-history-element (found in
>> > minibuffer-local-must-match-map), which is an interactive compiled
>> > Lisp function in ‘simple.el’.
>>
>> Cheers,
>>
>> > HY
>>




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
  2021-06-23  7:48         ` Omar Polo
@ 2021-06-23  8:56           ` Hongyi Zhao
  2021-06-23  9:17             ` Hongyi Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-06-23  8:56 UTC (permalink / raw)
  To: Omar Polo; +Cc: help-gnu-emacs

On Wed, Jun 23, 2021 at 3:49 PM Omar Polo <op@omarpolo.com> wrote:
>
> (sorry for the delay)
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > On Sat, Jun 19, 2021 at 11:57 PM Omar Polo <op@omarpolo.com> wrote:
> >>
> >>
> >> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> >>
> >> > On Sat, Jun 19, 2021 at 10:48 PM Omar Polo <op@omarpolo.com> wrote:
> >> >>
> >> >>
> >> >> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> >> >>
> >> >> > Dear all,
> >> >> >
> >> >> > Are there any built-in method of Emacs which can let me conveniently
> >> >> > check/inspect/retrieve the definition/usage of any
> >> >> > commands/symbols/operators used in elisp code at-the-point/in-situ?
> >> >> > Say, for the following code snippets:
> >> >> >
> >> >> > ;;;
> >> >> >   (defun fk/company-wordfreq-toggle-language (&optional language)
> >> >> >     (interactive)
> >> >> >     (setq ispell-local-dictionary (or language
> >> >> >                                       (if (string=
> >> >> > ispell-local-dictionary "english")
> >> >> >                                           "turkish"
> >> >> >                                         "english")))
> >> >> > [...]
> >> >> >   `(progn
> >> >> >     ,@(mapcar (lambda (p) `(use-package ,p))
> >> >> >               packages)))
> >> >> >
> >> >> > (use-multiple-packages flycheck
> >> >> >                        dash
> >> >> >                        )
> >> >> >
> >> >> > [...]
> >> >> > (mapcar #'straight-use-package '(flycheck lsp-mode dash ...))
> >> >> >
> >> >> > ;or equivalently
> >> >> >
> >> >> > (defvar my-package-list '(flycheck lsp-mode dash ...))
> >> >> > (mapcar #'straight-use-package my-package-list)
> >> >> > ;;;
> >> >> >
> >> >> > I want to find some convenient methods built in Emacs itself with an
> >> >> > in-situ manner - by moving the point to the interest position - to
> >> >> > check any commands/symbols/operators used in them.
> >> >> >
> >> >> > Regards
> >> >>
> >> >> there is M-. (xref-find-definitions) that will jump to the definition of
> >> >> the symbol at point (at least in emacs lisp buffers),
> >> >
> >> > Thank you very much. But still there are some symbols can't find with
> >> > this method, say, #'  ,@  ' and so on.
> >>
> >> #' ' ` , and ,@ aren't symbols, they are reader macros, i.e. special
> >> character sequences that the lisp reader expands into some special
> >> constructs.  For instance, #'foo is the same as (function 'foo) and 'foo
> >> the same as (quote foo).
> >>
> >> If you M-. with the point over quote (in an elisp buffer) it should jump
> >> to eval.c (assuming you have the C source files available).
> >>
> >> >> and M-, (xref-pop-marker-stack) to jump back.
> >> >
> >> > I use scratch buffer to test, and it can't jump back there.
> >>
> >> M-, is meant to be used after one or more M-.
> >>
> >> For instance:
> >>
> >> 1. in *scratch* type describe-function
> >> 2. press M-. -- it'll jump to help-fns.el.gz
> >> 3. move the point over with-help-window (something like ~10 lines below)
> >> 4. M-. again -- it'll jump to a different place in the same file
> >> 5. go back with M-, -- now you're back in the definition of
> >>    describe-function
> >> 6. M-, again -- now you're back in the *scratch* buffer
> >
> > Wonderful explanations. But I still failed to reproduce the M-, , as
> > for the other steps you told above except the last two, I can
> > reproduce them exactly the same as you described.
> >
> > See the attachment for the info I saw on the bottom mini-buffer when
> > hitting M-, (M- comma).
>
> don't want to sound rude, but could you please refrain from attaching a
> whole screenshot just for an error message?  Copying the error, like:
>
> "it says that: buffer is read-only"
>
> it's enough IMHO.  (you'll find a copy of the error message in the
> *Messages* buffer if you don't want to type it by hand.)
>
> Now, usually that error is signaled when you try to insert something
> into a buffer that read-only.  There can be multiple reasons for that,
> but unfortunately I thinks it's something on your end, since I cannot
> reproduce with `emacs -Q'.  Make sure that you are hitting M-, and not
> the comma alone, or ensure that M-, is bound to xref-pop-marker-stack
> and not to something else (C-h k M-,)

Thank you very much. Because of my negligence, the real input sequence
I've tried before is as follows:

(C-h k M-')

>
> As en extreme solution, try to enable the debug-on-error (M-x
> toggle-debug-on-error RET) and look at the stacktrace when that error
> happens.  (You can use toggle-debug-on-error again to disable it later)
>
> >>
> >> >>
> >> >> Or you can C-h f or C-h v (describe-function/variable) and then M-n
> >> >> (next-history-element) to bring in the symbol at point.
> >> >
> >> > I meet the following message: M-n is undefined, as shown in the
> >> > attached screenshot file.
> >>
> >> M-n should be defined in some minibuffer maps; with `emacs -Q' I can
> >>
> >>         C-h v C-h k M-n
> >>
> >> and it tells me that.
> >
> > I got the following with your above command sequence:
> >
> > M-n runs the command next-history-element (found in
> > minibuffer-local-must-match-map), which is an interactive compiled
> > Lisp function in ‘simple.el’.
> >
> > It is bound to <XF86Forward>, <next>, M-n, <menu-bar> <minibuf>
> > <next>.
> >
> > (next-history-element N)
> >
> > Puts next element of the minibuffer history in the minibuffer.
> > With argument N, it uses the Nth following element.  The position
> > in the history can go beyond the current position and invoke "future
> > history."
>
> Yep.  Sorry for giving a long command sequence without any explanation.
> `C-h v' is describe-variable, it should enter the minibuffer asking for
> a variable to be described.  Then `C-h k' is describe-key, that works in
> the minibuffer too.  M-n is bound to next-history-element there too, so
> it should work.  When you are over (or at the beginning) of a symbol,
> M-n should pull that symbol into the minibuffer.  So with the cursor
> over
>
>         toggle-debug-on-error
>
> if I type `C-h f' (describe-function) and then M-n, Emacs automatically
> inserts "toggle-debug-on-error" as input in the minibuffer.  Then I can
> simply RET to read the documentation of the function :)

Wonderful. Got it. Thank you very much again.

HY

>
> > HY
> >
> >>
> >> > M-n runs the command next-history-element (found in
> >> > minibuffer-local-must-match-map), which is an interactive compiled
> >> > Lisp function in ‘simple.el’.
> >>
> >> Cheers,
> >>
> >> > HY
> >>
>


-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code.
  2021-06-23  8:56           ` Hongyi Zhao
@ 2021-06-23  9:17             ` Hongyi Zhao
  2021-06-23  9:31               ` Screenshots, frame shots straight from Emacs Jean Louis
  0 siblings, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-06-23  9:17 UTC (permalink / raw)
  To: Omar Polo; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 7820 bytes --]

On Wed, Jun 23, 2021 at 4:56 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Wed, Jun 23, 2021 at 3:49 PM Omar Polo <op@omarpolo.com> wrote:
> >
> > (sorry for the delay)
> >
> > Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> >
> > > On Sat, Jun 19, 2021 at 11:57 PM Omar Polo <op@omarpolo.com> wrote:
> > >>
> > >>
> > >> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> > >>
> > >> > On Sat, Jun 19, 2021 at 10:48 PM Omar Polo <op@omarpolo.com> wrote:
> > >> >>
> > >> >>
> > >> >> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> > >> >>
> > >> >> > Dear all,
> > >> >> >
> > >> >> > Are there any built-in method of Emacs which can let me
conveniently
> > >> >> > check/inspect/retrieve the definition/usage of any
> > >> >> > commands/symbols/operators used in elisp code
at-the-point/in-situ?
> > >> >> > Say, for the following code snippets:
> > >> >> >
> > >> >> > ;;;
> > >> >> >   (defun fk/company-wordfreq-toggle-language (&optional
language)
> > >> >> >     (interactive)
> > >> >> >     (setq ispell-local-dictionary (or language
> > >> >> >                                       (if (string=
> > >> >> > ispell-local-dictionary "english")
> > >> >> >                                           "turkish"
> > >> >> >                                         "english")))
> > >> >> > [...]
> > >> >> >   `(progn
> > >> >> >     ,@(mapcar (lambda (p) `(use-package ,p))
> > >> >> >               packages)))
> > >> >> >
> > >> >> > (use-multiple-packages flycheck
> > >> >> >                        dash
> > >> >> >                        )
> > >> >> >
> > >> >> > [...]
> > >> >> > (mapcar #'straight-use-package '(flycheck lsp-mode dash ...))
> > >> >> >
> > >> >> > ;or equivalently
> > >> >> >
> > >> >> > (defvar my-package-list '(flycheck lsp-mode dash ...))
> > >> >> > (mapcar #'straight-use-package my-package-list)
> > >> >> > ;;;
> > >> >> >
> > >> >> > I want to find some convenient methods built in Emacs itself
with an
> > >> >> > in-situ manner - by moving the point to the interest position -
to
> > >> >> > check any commands/symbols/operators used in them.
> > >> >> >
> > >> >> > Regards
> > >> >>
> > >> >> there is M-. (xref-find-definitions) that will jump to the
definition of
> > >> >> the symbol at point (at least in emacs lisp buffers),
> > >> >
> > >> > Thank you very much. But still there are some symbols can't find
with
> > >> > this method, say, #'  ,@  ' and so on.
> > >>
> > >> #' ' ` , and ,@ aren't symbols, they are reader macros, i.e. special
> > >> character sequences that the lisp reader expands into some special
> > >> constructs.  For instance, #'foo is the same as (function 'foo) and
'foo
> > >> the same as (quote foo).
> > >>
> > >> If you M-. with the point over quote (in an elisp buffer) it should
jump
> > >> to eval.c (assuming you have the C source files available).
> > >>
> > >> >> and M-, (xref-pop-marker-stack) to jump back.
> > >> >
> > >> > I use scratch buffer to test, and it can't jump back there.
> > >>
> > >> M-, is meant to be used after one or more M-.
> > >>
> > >> For instance:
> > >>
> > >> 1. in *scratch* type describe-function
> > >> 2. press M-. -- it'll jump to help-fns.el.gz
> > >> 3. move the point over with-help-window (something like ~10 lines
below)
> > >> 4. M-. again -- it'll jump to a different place in the same file
> > >> 5. go back with M-, -- now you're back in the definition of
> > >>    describe-function
> > >> 6. M-, again -- now you're back in the *scratch* buffer
> > >
> > > Wonderful explanations. But I still failed to reproduce the M-, , as
> > > for the other steps you told above except the last two, I can
> > > reproduce them exactly the same as you described.
> > >
> > > See the attachment for the info I saw on the bottom mini-buffer when
> > > hitting M-, (M- comma).
> >
> > don't want to sound rude, but could you please refrain from attaching a
> > whole screenshot just for an error message?  Copying the error, like:
> >
> > "it says that: buffer is read-only"
> >
> > it's enough IMHO.  (you'll find a copy of the error message in the
> > *Messages* buffer if you don't want to type it by hand.)
> >
> > Now, usually that error is signaled when you try to insert something
> > into a buffer that read-only.  There can be multiple reasons for that,
> > but unfortunately I thinks it's something on your end, since I cannot
> > reproduce with `emacs -Q'.  Make sure that you are hitting M-, and not
> > the comma alone, or ensure that M-, is bound to xref-pop-marker-stack
> > and not to something else (C-h k M-,)
>
> Thank you very much. Because of my negligence, the real input sequence
> I've tried before is as follows:
>
> (C-h k M-')

Then I put the cursor on the result buffer which describing M-'  , then I
hit M-' again. Now, the following screenshot will be triggered:


[image: 2021-06-23_16-59.png]
I hope this time I clearly expressed all of my key sequences.

HY
>
> >
> > As en extreme solution, try to enable the debug-on-error (M-x
> > toggle-debug-on-error RET) and look at the stacktrace when that error
> > happens.  (You can use toggle-debug-on-error again to disable it later)
> >
> > >>
> > >> >>
> > >> >> Or you can C-h f or C-h v (describe-function/variable) and then
M-n
> > >> >> (next-history-element) to bring in the symbol at point.
> > >> >
> > >> > I meet the following message: M-n is undefined, as shown in the
> > >> > attached screenshot file.
> > >>
> > >> M-n should be defined in some minibuffer maps; with `emacs -Q' I can
> > >>
> > >>         C-h v C-h k M-n
> > >>
> > >> and it tells me that.
> > >
> > > I got the following with your above command sequence:
> > >
> > > M-n runs the command next-history-element (found in
> > > minibuffer-local-must-match-map), which is an interactive compiled
> > > Lisp function in ‘simple.el’.
> > >
> > > It is bound to <XF86Forward>, <next>, M-n, <menu-bar> <minibuf>
> > > <next>.
> > >
> > > (next-history-element N)
> > >
> > > Puts next element of the minibuffer history in the minibuffer.
> > > With argument N, it uses the Nth following element.  The position
> > > in the history can go beyond the current position and invoke "future
> > > history."
> >
> > Yep.  Sorry for giving a long command sequence without any explanation.
> > `C-h v' is describe-variable, it should enter the minibuffer asking for
> > a variable to be described.  Then `C-h k' is describe-key, that works in
> > the minibuffer too.  M-n is bound to next-history-element there too, so
> > it should work.  When you are over (or at the beginning) of a symbol,
> > M-n should pull that symbol into the minibuffer.  So with the cursor
> > over
> >
> >         toggle-debug-on-error
> >
> > if I type `C-h f' (describe-function) and then M-n, Emacs automatically
> > inserts "toggle-debug-on-error" as input in the minibuffer.  Then I can
> > simply RET to read the documentation of the function :)
>
> Wonderful. Got it. Thank you very much again.
>
> HY
>
> >
> > > HY
> > >
> > >>
> > >> > M-n runs the command next-history-element (found in
> > >> > minibuffer-local-must-match-map), which is an interactive compiled
> > >> > Lisp function in ‘simple.el’.
> > >>
> > >> Cheers,
> > >>
> > >> > HY
> > >>
> >
>
>
> --
> Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
> Theory and Simulation of Materials
> Hebei Vocational University of Technology and Engineering
> NO. 552 North Gangtie Road, Xingtai, China



-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China

[-- Attachment #2: 2021-06-23_16-59.png --]
[-- Type: image/png, Size: 87037 bytes --]

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Screenshots, frame shots straight from Emacs
  2021-06-23  9:17             ` Hongyi Zhao
@ 2021-06-23  9:31               ` Jean Louis
  2021-06-25 22:04                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-23  0:52                 ` Hongyi Zhao
  0 siblings, 2 replies; 62+ messages in thread
From: Jean Louis @ 2021-06-23  9:31 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs, Omar Polo

As you like screenshots, here is one way to generate Emacs frame shots
straight from Emacs without using external programs:

(defvar frameshot-directory "~/Media/Pictures/Screenshots/"
  "Default directory for frame shots")

(defvar frameshot-format 'png
  "Default frame shot format, could be 'jpg or 'svg, inspect the
  function `x-export-frames'")

(defun frameshot ()
  "Save Emacs frame as frame shot.

Directory is determined by variable `frameshot-directory' and if
not defined, it will be saved in the `$HOME' directory."
  (interactive)
  (let* ((image (x-export-frames nil (or frameshot-format 'png)))
	 (base-directory (or frameshot-directory (getenv "HOME")))
	 (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
	 (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
    (make-directory directory t)
    (with-temp-file file
      (insert image))
    (find-file directory)
    (message "Frame shot saved as `%s'" file)))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-06-23  9:31               ` Screenshots, frame shots straight from Emacs Jean Louis
@ 2021-06-25 22:04                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-06-25 22:34                   ` Jean Louis
  2021-07-20 11:36                   ` Tomas Hlavaty
  2021-07-23  0:52                 ` Hongyi Zhao
  1 sibling, 2 replies; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-25 22:04 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> As you like screenshots, here is one way to generate Emacs
> frame shots straight from Emacs without using external
> programs

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/vt.el
;;;   https://dataswamp.org/~incal/emacs-init/vt.el

(defun dump (desc)
  (interactive "sdescription: ")
  (message nil)
  (let ((file (format "~/%s.png" desc)))
    (shell-command (format "sudo fbgrab %s" file))
    (shell-command (format "sudo chown %s %s" user-login-name file))
    (shell-command (format "sudo chgrp %s %s" user-login-name file)) ))

https://dataswamp.org/~incal/figures/emacs/

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-06-25 22:04                 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-06-25 22:34                   ` Jean Louis
  2021-06-25 23:55                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-20 11:36                   ` Tomas Hlavaty
  1 sibling, 1 reply; 62+ messages in thread
From: Jean Louis @ 2021-06-25 22:34 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-26 01:06]:
> Jean Louis wrote:
> 
> > As you like screenshots, here is one way to generate Emacs
> > frame shots straight from Emacs without using external
> > programs
> 
> ;;; -*- lexical-binding: t -*-
> ;;;
> ;;; this file:
> ;;;   http://user.it.uu.se/~embe8573/emacs-init/vt.el
> ;;;   https://dataswamp.org/~incal/emacs-init/vt.el
> 
> (defun dump (desc)
>   (interactive "sdescription: ")
>   (message nil)
>   (let ((file (format "~/%s.png" desc)))
>     (shell-command (format "sudo fbgrab %s" file))
>     (shell-command (format "sudo chown %s %s" user-login-name file))
>     (shell-command (format "sudo chgrp %s %s" user-login-name file)) ))


Sudo for screenshot? ( ◔ ʖ̯ ◔ )

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-06-25 22:34                   ` Jean Louis
@ 2021-06-25 23:55                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-06-28  6:47                       ` Jean Louis
  0 siblings, 1 reply; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-25 23:55 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> (defun dump (desc)
>>   (interactive "sdescription: ")
>>   (message nil)
>>   (let ((file (format "~/%s.png" desc)))
>>     (shell-command (format "sudo fbgrab %s" file))
>>     (shell-command (format "sudo chown %s %s" user-login-name file))
>>     (shell-command (format "sudo chgrp %s %s" user-login-name file)) ))
>
> Sudo for screenshot?

Leftovers, alright then -

(defun dump (name)
  (interactive "sname: ")
  (message nil)
  (let ((file (format "~/%s.png" name)))
    (shell-command (format "fbgrab %s" file)) ))

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-06-25 23:55                     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-06-28  6:47                       ` Jean Louis
  2021-07-01 21:01                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 62+ messages in thread
From: Jean Louis @ 2021-06-28  6:47 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <moasenwood@zoho.eu> [2021-06-25 19:55]:
> Jean Louis wrote:
> 
> >> (defun dump (desc)
> >>   (interactive "sdescription: ")
> >>   (message nil)
> >>   (let ((file (format "~/%s.png" desc)))
> >>     (shell-command (format "sudo fbgrab %s" file))
> >>     (shell-command (format "sudo chown %s %s" user-login-name file))
> >>     (shell-command (format "sudo chgrp %s %s" user-login-name file)) ))
> >
> > Sudo for screenshot?
> 
> Leftovers, alright then -
> 
> (defun dump (name)
>   (interactive "sname: ")
>   (message nil)
>   (let ((file (format "~/%s.png" name)))
>     (shell-command (format "fbgrab %s" file)) ))

External program is dependency.

Emacs has internal function for it,.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-06-28  6:47                       ` Jean Louis
@ 2021-07-01 21:01                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-02 12:50                           ` Jean Louis
  0 siblings, 1 reply; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-01 21:01 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> External program is dependency.
>
> Emacs has internal function for it,.

It does? The only thing I can find is
`message-insert-screenshot'. It uses what's in
`message-screenshot-command', which here is ("import" "png:-")

That's a command? Not in the interactive function sense,
at least.

Anyway, I use fbgrab(1) from outside of Emacs as well so for
me it is natural to invoke that from Emacs as well.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-01 21:01                         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-02 12:50                           ` Jean Louis
  2021-07-02 15:34                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 62+ messages in thread
From: Jean Louis @ 2021-07-02 12:50 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-07-02 00:02]:
> Jean Louis wrote:
> 
> > External program is dependency.
> >
> > Emacs has internal function for it,.
> 
> It does? The only thing I can find is
> `message-insert-screenshot'. It uses what's in
> `message-screenshot-command', which here is ("import" "png:-")
> 
> That's a command? Not in the interactive function sense,
> at least.

You responded on the function: (x-export-frames nil (or
frameshot-format 'png)))

so watch for it below:

(defvar frameshot-directory "~/Media/Pictures/Screenshots/"
  "Default directory for frame shots")

(defvar frameshot-format 'png
  "Default frame shot format")

(defun frameshot ()
  "Save Emacs frame as frame shot.

Directory is determined by variable `frameshot-directory' and if
not defined, it will be saved in the `$HOME' directory."
  (interactive)
  (let* ((image (x-export-frames nil (or frameshot-format 'png)))
	 (base-directory (or frameshot-directory (getenv "HOME")))
	 (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
	 (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
    (make-directory directory t)
    (with-temp-file file
      (insert image))
    (find-file directory)
    (message "Frame shot saved as `%s'" file)))


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-02 12:50                           ` Jean Louis
@ 2021-07-02 15:34                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-02 15:34 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> (defvar frameshot-directory "~/Media/Pictures/Screenshots/"
>   "Default directory for frame shots")
>
> (defvar frameshot-format 'png
>   "Default frame shot format")

What's with all the global vars...

> (defun frameshot ()
>   "Save Emacs frame as frame shot.
> Directory is determined by variable `frameshot-directory' and if
> not defined, it will be saved in the `$HOME' directory."
>   (interactive)
>   (let* ((image (x-export-frames nil (or frameshot-format 'png)))
> 	 (base-directory (or frameshot-directory (getenv "HOME")))
> 	 (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
> 	 (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
>     (make-directory directory t)
>     (with-temp-file file
>       (insert image))
>     (find-file directory)
>     (message "Frame shot saved as `%s'" file)))

OK, cool.

This is what I do outside of Emacs (it can be used for Emacs
as well, if the VT is specified) - number 1, tty1 - or, again,
if invoked from Emacs with the designated defun.

The Linux VT / X issue, again, but here not really a problem
since so easy on both accounts. Or so good provided already,
maybe I should say.

#! /bin/zsh
#
# this file:
#   http://user.it.uu.se/~embe8573/conf/.zsh/dump
#   https://dataswamp.org/~incal/conf/.zsh/dump

last-arg () {
    echo ${@:${#@}}
}

dump-vt () {
    local vt=$1
    local file=$(last-arg $@).png # so it'll also work when $# = 1
    case $# in
        (1) fbgrab             $file ;;
        (2) sudo fbgrab -c $vt $file &&
            sudo chown $USER   $file &&
            sudo chgrp $USER   $file ;;
    esac
}
alias dumpvt=dump-vt

dump-x () {
    local name=$1
    local file=${name}.png
    local win_name=$2
    case $# in
        (1) gnome-screenshot -d 5  -f $file ;;
        (2) wmctrl -a $win_name             &&
            gnome-screenshot -w -B -f $file ;;
    esac 2> /dev/null
}

dump () {
    [[ $DISPLAY ]] && dump-x $@ || dump-vt $@
}

and from Emacs:

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/vt.el
;;;   https://dataswamp.org/~incal/emacs-init/vt.el

(defun dump (name)
  (interactive "sname: ")
  (message nil)
  (let ((file (format "~/%s.png" name)))
    (shell-command (format "fbgrab %s" file)) ))

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-06-25 22:04                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-06-25 22:34                   ` Jean Louis
@ 2021-07-20 11:36                   ` Tomas Hlavaty
  2021-07-20 17:42                     ` Leo Butler
  2021-07-21  3:34                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 2 replies; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-20 11:36 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat 26 Jun 2021 at 00:04, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> Jean Louis wrote:
>> As you like screenshots, here is one way to generate Emacs
>> frame shots straight from Emacs without using external
>> programs

that one requires GUI emacs

> (defun dump (desc)
>   (interactive "sdescription: ")
>   (message nil)
>   (let ((file (format "~/%s.png" desc)))
>     (shell-command (format "sudo fbgrab %s" file))
>     (shell-command (format "sudo chown %s %s" user-login-name file))
>     (shell-command (format "sudo chgrp %s %s" user-login-name file)) ))

the above one requires external programs

this one works with plain console emacs:
https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l755



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 11:36                   ` Tomas Hlavaty
@ 2021-07-20 17:42                     ` Leo Butler
  2021-07-20 19:44                       ` Tomas Hlavaty
  2021-07-21  3:34                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 62+ messages in thread
From: Leo Butler @ 2021-07-20 17:42 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

Tomas Hlavaty <tom@logand.com> writes:

> this one works with plain console emacs:
> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l755

Nice. I have not tried it yet, but I do notice that

https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l28

requires cl.

Also, when byte-compiling the file, I ran into 3 warnings which are easy
to correct (see attached). I still haven't got it working, but I think
that is due to user error.

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 1337 bytes --]

diff --git a/emacs-framebuffer.el b/emacs-framebuffer.el
index ce9334e..e339a4f 100644
--- a/emacs-framebuffer.el
+++ b/emacs-framebuffer.el
@@ -25,7 +25,7 @@
 ;;; (require 'emacs-framebuffer)
 ;;; (framebuffer-install)
 
-(require 'cl)
+(require 'cl-lib)
 
 (defcustom framebuffer-w3mimgdisplay-program nil
   "Specify the path to w3mimgdisplay program."
@@ -201,6 +201,9 @@
       (framebuffer-file-exists-p "/usr/lib/w3m/w3mimgdisplay") ;; debian10
       "w3mimgdisplay"))
 
+(make-variable-buffer-local
+ (defvar framebuffer-image-mode-current-page))
+
 (defun framebuffer-draw (x y w h sx sy sw sh file)
   (setq file (framebuffer-cache-remote file))
   (let ((format (framebuffer-file-format file)))
@@ -465,8 +468,6 @@
  (defvar framebuffer-image-mode-image-size))
 (make-variable-buffer-local
  (defvar framebuffer-image-mode-npages))
-(make-variable-buffer-local
- (defvar framebuffer-image-mode-current-page))
 (make-variable-buffer-local
  (defvar framebuffer-image-mode-scale))
 (make-variable-buffer-local
@@ -663,7 +664,7 @@
     (integer
      (let* ((m (mod sec 3600))
 	    (s (mod m 60)))
-       (format "%d:%02d:%02d" (floor position 3600) (floor (- m s) 60) s)))))
+       (format "%d:%02d:%02d" (floor sec 3600) (floor (- m s) 60) s)))))
 
 (defun framebuffer-fbmpv (filename &optional position)
   (suspend-emacs

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 17:42                     ` Leo Butler
@ 2021-07-20 19:44                       ` Tomas Hlavaty
  2021-07-20 20:21                         ` Leo Butler
  2021-07-20 21:48                         ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-20 19:44 UTC (permalink / raw)
  To: Leo Butler; +Cc: help-gnu-emacs

Hi Leo,

On Tue 20 Jul 2021 at 12:42, Leo Butler <leo.butler@umanitoba.ca> wrote:
> Tomas Hlavaty <tom@logand.com> writes:
>
>> this one works with plain console emacs:
>> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l755
>
> Nice. I have not tried it yet, but I do notice that

thanks for your feedback!

> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l28
>
> requires cl.
>
> Also, when byte-compiling the file, I ran into 3 warnings which are easy
> to correct (see attached). I still haven't got it working, but I think
> that is due to user error.

What Emacs version are you using?

In Emacs 27.2, I get 2 warnings:

emacs-framebuffer.el:28:1:Warning: cl package required at runtime

and

In framebuffer-hh:mm:ss:
emacs-framebuffer.el:666:38:Warning: reference to free variable ‘position’

The first one does not break anything.

The second one is a bug relevant only for viewing videos on the console
from a chosen position.

None of them break screenshot functionality.

There is /dev/fb0 hardcoded so this might cause problems for some but I
actually never experienced any other device.  It would be interesting to
know, how to properly detect which device is actually used if there are
more than one.

> -(require 'cl)
> +(require 'cl-lib)

What is the difference?  Why is that needed?  Is it it backward
compatible?  There have been changes to working with cl package for some
time, has the dust settled yet?

> +(make-variable-buffer-local
> + (defvar framebuffer-image-mode-current-page))
> +
>  (defun framebuffer-draw (x y w h sx sy sw sh file)
>    (setq file (framebuffer-cache-remote file))
>    (let ((format (framebuffer-file-format file)))
> @@ -465,8 +468,6 @@
>   (defvar framebuffer-image-mode-image-size))
>  (make-variable-buffer-local
>   (defvar framebuffer-image-mode-npages))
> -(make-variable-buffer-local
> - (defvar framebuffer-image-mode-current-page))

I seems to be necessary to have these defined before use so I will
probably move those to the beginning of the file.

I did not get a warning for this.  Did you get a warning?

> -       (format "%d:%02d:%02d" (floor position 3600) (floor (- m s) 60) s)))))
> +       (format "%d:%02d:%02d" (floor sec 3600) (floor (- m s) 60) s)))))

Thanks, I'll fix this typo.

Tomas



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 19:44                       ` Tomas Hlavaty
@ 2021-07-20 20:21                         ` Leo Butler
  2021-07-20 20:50                           ` Tomas Hlavaty
  2021-07-20 21:51                           ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-20 21:48                         ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 2 replies; 62+ messages in thread
From: Leo Butler @ 2021-07-20 20:21 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Tomas Hlavaty <tom@logand.com> writes:

> ********************************************************
> Caution: This message was sent from outside the University of Manitoba.
> ********************************************************
>
> Hi Leo,
>
> On Tue 20 Jul 2021 at 12:42, Leo Butler <leo.butler@umanitoba.ca> wrote:
>> Tomas Hlavaty <tom@logand.com> writes:
>>
>>> this one works with plain console emacs:
>>> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l755
>>
>> Nice. I have not tried it yet, but I do notice that
>
> thanks for your feedback!
>
>> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l28
>>
>> requires cl.
>>
>> Also, when byte-compiling the file, I ran into 3 warnings which are easy
>> to correct (see attached). I still haven't got it working, but I think
>> that is due to user error.
>
> What Emacs version are you using?

M-x emacs-version

GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24,
cairo version 1.16.0) of 2021-03-27, modified by Debian

>
> In Emacs 27.2, I get 2 warnings:
>
> emacs-framebuffer.el:28:1:Warning: cl package required at runtime
>
> and
>
> In framebuffer-hh:mm:ss:
> emacs-framebuffer.el:666:38:Warning: reference to free variable ‘position’
>
> The first one does not break anything.
>
> The second one is a bug relevant only for viewing videos on the console
> from a chosen position.
>
> None of them break screenshot functionality.
>
> There is /dev/fb0 hardcoded so this might cause problems for some but I
> actually never experienced any other device.  It would be interesting to
> know, how to properly detect which device is actually used if there are
> more than one.
>
>> -(require 'cl)
>> +(require 'cl-lib)
>
> What is the difference?  Why is that needed?  Is it it backward
> compatible?  There have been changes to working with cl package for some
> time, has the dust settled yet?

I think cl was officially deprecated in v27, so if I start emacs as a
daemon and my .emacs tries to pull in cl, emacs freezes.

>
>> +(make-variable-buffer-local
>> + (defvar framebuffer-image-mode-current-page))
>> +
>>  (defun framebuffer-draw (x y w h sx sy sw sh file)
>>    (setq file (framebuffer-cache-remote file))
>>    (let ((format (framebuffer-file-format file)))
>> @@ -465,8 +468,6 @@
>>   (defvar framebuffer-image-mode-image-size))
>>  (make-variable-buffer-local
>>   (defvar framebuffer-image-mode-npages))
>> -(make-variable-buffer-local
>> - (defvar framebuffer-image-mode-current-page))
>
> I seems to be necessary to have these defined before use so I will
> probably move those to the beginning of the file.

Yes.

>
> I did not get a warning for this.  Did you get a warning?

Yes, I did.

>
>> -       (format "%d:%02d:%02d" (floor position 3600) (floor (- m s) 60) s)))))
>> +       (format "%d:%02d:%02d" (floor sec 3600) (floor (- m s) 60) s)))))
>
> Thanks, I'll fix this typo.

I'll try to get it working on my installation when I have time. It's
great to be able to do this sort of thing.

Leo



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 20:21                         ` Leo Butler
@ 2021-07-20 20:50                           ` Tomas Hlavaty
  2021-07-31 23:25                             ` Tomas Hlavaty
  2021-07-20 21:51                           ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-20 20:50 UTC (permalink / raw)
  To: Leo Butler; +Cc: help-gnu-emacs

On Tue 20 Jul 2021 at 15:21, Leo Butler <leo.butler@umanitoba.ca> wrote:
> Tomas Hlavaty <tom@logand.com> writes:
>> On Tue 20 Jul 2021 at 12:42, Leo Butler <leo.butler@umanitoba.ca> wrote:
>>> -(require 'cl)
>>> +(require 'cl-lib)
>>
>> What is the difference?  Why is that needed?  Is it it backward
>> compatible?  There have been changes to working with cl package for some
>> time, has the dust settled yet?
>
> I think cl was officially deprecated in v27, so if I start emacs as a
> daemon and my .emacs tries to pull in cl, emacs freezes.

strange, my emacs works fine

but if that's the case, I will update it

>> I did not get a warning for this.  Did you get a warning?
>
> Yes, I did.

strange

> I'll try to get it working on my installation when I have time. It's
> great to be able to do this sort of thing.

I'll push the fixes at the end of this week when I have better internet
connection.

Thank you!

Tomas



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 19:44                       ` Tomas Hlavaty
  2021-07-20 20:21                         ` Leo Butler
@ 2021-07-20 21:48                         ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-21 19:17                           ` Leo Butler
                                             ` (2 more replies)
  1 sibling, 3 replies; 62+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-20 21:48 UTC (permalink / raw)
  To: help-gnu-emacs

>> -(require 'cl)
>> +(require 'cl-lib)
> What is the difference?

They provide the same features but under different names (i.e. the
above change should generally come with other changes to adjust to the
different names; they seemed to be missing from the patch).

E.g. `cl` provides `position` and `mapcar*` whereas `cl-lib` provides
`cl-position` and `cl-mapcar`.  All the functions/macros/variables
exported by `cl-lib` use the `cl-` prefix.

[ Note that in Emacs≥24.3, `(require 'cl)` will require `cl-lib` under
  the hood (and then re-export its functions under the old name), and
  the reverse holds for Emacs<24.3 if you use the forward compatibility
  `cl-lib` package from GNU ELPA.  So loading `cl` may also sometimes
  end up defining the `cl-<foo>` functions, and loading `cl-lib` may
  also sometimes define the "not cl-<foo>" functions.  ]

> Why is that needed?

Because `cl` is deprecated.

> Is it it backward compatible?

Featurewise, almost.  But it does require code changes (mostly adding
`cl-` prefixes).

> There have been changes to working with cl package for some time, has
> the dust settled yet?

AFAIK the dust settled back when Emacs-24.3 was released with `cl-lib`.
`cl-lib` was slated to (slowly) replace `cl`.  In the upcoming Emacs-28,
`cl` is officially deprecated (tho still fully supported).  In some
future release the plan is to remove `cl` from Emacs itself, tho we
may then create a GNU ELPA package for it.

IOW, there's no hurry, but moving packages away from `cl` is
recommended (as is the conversion to use `lexical-binding`: all files
bundled with Emacs-28 use `lexical-binding`).


        Stefan




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 20:21                         ` Leo Butler
  2021-07-20 20:50                           ` Tomas Hlavaty
@ 2021-07-20 21:51                           ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 62+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-20 21:51 UTC (permalink / raw)
  To: help-gnu-emacs

> I think cl was officially deprecated in v27,

Oh, you're right we did it in Emacs-27 already (not sure why I thought
it was only for Emacs-28).

> so if I start Emacs as a daemon and my .emacs tries to pull in cl,
> emacs freezes.

Hmm... that's not normal; it sounds like a bug.


        Stefan




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 11:36                   ` Tomas Hlavaty
  2021-07-20 17:42                     ` Leo Butler
@ 2021-07-21  3:34                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-21 17:21                       ` Leo Butler
  2021-07-22  8:16                       ` Tomas Hlavaty
  1 sibling, 2 replies; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-21  3:34 UTC (permalink / raw)
  To: help-gnu-emacs

Tomas Hlavaty wrote:

> this one works with plain console emacs:
> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l755

Wow, looks interesting! Testing now! ...

YIKES!!!

https://dataswamp.org/~incal/figures/emacs/framebuffer-draw-test.png

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-21  3:34                     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-21 17:21                       ` Leo Butler
  2021-07-21 17:52                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-22  8:26                         ` Tomas Hlavaty
  2021-07-22  8:16                       ` Tomas Hlavaty
  1 sibling, 2 replies; 62+ messages in thread
From: Leo Butler @ 2021-07-21 17:21 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Tomas Hlavaty wrote:
>
>> this one works with plain console emacs:
>> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l755
>
> Wow, looks interesting! Testing now! ...
>
> YIKES!!!
>
> https://dataswamp.org/~incal/figures/emacs/framebuffer-draw-test.png

Did you take the screenshot in a *console*?

Here is an example done from a console:


[-- Attachment #2: screenshot-20210721-121112.jpg --]
[-- Type: image/jpeg, Size: 124400 bytes --]

[-- Attachment #3: Type: text/plain, Size: 243 bytes --]


I did:

M-x eval-buffer RET
M-x framebuffer-screenshot RET
M-! ppmtojpg ... > ...

@Tomas:

I am not sure why, but when I do the same thing in an xterm (in the same
emacs session, but with a different client, obviously), I end up with
this:


[-- Attachment #4: screenshot-20210721-121740.jpg --]
[-- Type: image/jpeg, Size: 65233 bytes --]

[-- Attachment #5: Type: text/plain, Size: 5 bytes --]


Leo

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-21 17:21                       ` Leo Butler
@ 2021-07-21 17:52                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-22  8:26                         ` Tomas Hlavaty
  1 sibling, 0 replies; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-21 17:52 UTC (permalink / raw)
  To: help-gnu-emacs

Leo Butler wrote:

>>> this one works with plain console emacs:
>>> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l755
>>
>> Wow, looks interesting! Testing now! ...
>>
>> YIKES!!!
>>
>> https://dataswamp.org/~incal/figures/emacs/framebuffer-draw-test.png
>
> Did you take the screenshot in a *console*?

Technically and specifically in /dev/tty1 AKA the console AKA
the Linux VT.

You better believe it :)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 21:48                         ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-21 19:17                           ` Leo Butler
  2021-07-21 20:05                             ` Stefan Monnier
  2021-07-22  8:37                           ` Screenshots, frame shots straight from Emacs Tomas Hlavaty
  2021-07-31 23:31                           ` Tomas Hlavaty
  2 siblings, 1 reply; 62+ messages in thread
From: Leo Butler @ 2021-07-21 19:17 UTC (permalink / raw)
  To: Stefan Monnier via Users list for the GNU Emacs text editor
  Cc: Stefan Monnier

Stefan Monnier via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

>>> -(require 'cl)
>>> +(require 'cl-lib)
>> What is the difference?
>
> They provide the same features but under different names (i.e. the
> above change should generally come with other changes to adjust to the
> different names; they seemed to be missing from the patch).

The byte compiler did not complain after making the change. I didn't
investigate further, but suspect that the requirement is unneeded.

Leo



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-21 19:17                           ` Leo Butler
@ 2021-07-21 20:05                             ` Stefan Monnier
  2021-07-21 21:44                               ` cl-lib questions (was: Re: Screenshots, frame shots straight from Emacs) Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 62+ messages in thread
From: Stefan Monnier @ 2021-07-21 20:05 UTC (permalink / raw)
  To: Leo Butler; +Cc: Stefan Monnier via Users list for the GNU Emacs text editor

>> They provide the same features but under different names (i.e. the
>> above change should generally come with other changes to adjust to the
>> different names; they seemed to be missing from the patch).
>
> The byte compiler did not complain after making the change. I didn't
> investigate further, but suspect that the requirement is unneeded.

Quite likely (unless it so happens that the package relies on one of
those `cl` features which were incorporated into core when `cl-lib` was
introduced, the main such feature being `setf`).


        Stefan




^ permalink raw reply	[flat|nested] 62+ messages in thread

* cl-lib questions (was: Re: Screenshots, frame shots straight from Emacs)
  2021-07-21 20:05                             ` Stefan Monnier
@ 2021-07-21 21:44                               ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-21 21:59                                 ` cl-lib questions Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-21 21:44 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

>> The byte compiler did not complain after making the change.
>> I didn't investigate further, but suspect that the
>> requirement is unneeded.
>
> Quite likely (unless it so happens that the package relies
> on one of those `cl` features which were incorporated into
> core when `cl-lib` was introduced, the main such feature
> being `setf`).

Can you perhaps say a couple of words on the intended use for
`setf', I get it it is a generic function (macro) but is there
in your mind say one or two typical use cases or something
like that to exemplify?

Also, what is the difference between setf and `setq' with
respect to setting `let'/`let*' variables?

E.g.,

  (let ((x "the truth is out there"))
    (setf x "with a special flavor for YOU")
    x)

  (let ((x "the truth is out there"))
    (setq x "with a special flavor for YOU")
    x)

both of which evaluate to "with a special flavor for YOU" ?

Another cl-lib question is the type of clause usable with
`cl-loop' that are described like this in the docstring:

  Accumulation clauses:
    collect/append/nconc/concat/vconcat/count/sum/maximize/minimize FORM
    [into VAR]

The reason I ask this here is that I have tried to use that
many times in order to not have setq/setf in loops, which you
BTW said were virtually equivalent in that setting IIRC, so my
question in, is it possible to use accumulation clauses
instead, and if so, how, and if not, then when, for what
purpose, and how are you supposed to use them?

TIA

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: cl-lib questions
  2021-07-21 21:44                               ` cl-lib questions (was: Re: Screenshots, frame shots straight from Emacs) Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-21 21:59                                 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-21 22:09                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 62+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-21 21:59 UTC (permalink / raw)
  To: help-gnu-emacs

> Can you perhaps say a couple of words on the intended use for
> `setf', I get it it is a generic function (macro) but is there
> in your mind say one or two typical use cases or something
> like that to exemplify?

A typical example for me is when you want to modify the field of
a struct:

    (cl-defstruct my-foo a b c)

then you can set the field `b` of a my-foo struct X to value V with:

    (setf (my-foo-b X) V)

I also like to (ab)use it for things like

    (push (make-new-element)
          (if (something)
              x
            y))

> Also, what is the difference between setf and `setq' with
> respect to setting `let'/`let*' variables?

None.

> Another cl-lib question is the type of clause usable with
> `cl-loop' that are described like this in the docstring:

I wouldn't know, I never use `cl-loop`.


        Stefan




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: cl-lib questions
  2021-07-21 21:59                                 ` cl-lib questions Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-21 22:09                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-21 22:09 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier via Users list for the GNU Emacs text editor wrote:

>> Can you perhaps say a couple of words on the intended use
>> for `setf', I get it it is a generic function (macro) but
>> is there in your mind say one or two typical use cases or
>> something like that to exemplify?
>
> A typical example for me is when you want to modify the field of
> a struct:
>
>     (cl-defstruct my-foo a b c)
>
> then you can set the field `b` of a my-foo struct X to value V with:
>
>     (setf (my-foo-b X) V)
>
> I also like to (ab)use it for things like
>
>     (push (make-new-element)
>           (if (something)
>               x
>             y))
>
>> Also, what is the difference between setf and `setq' with
>> respect to setting `let'/`let*' variables?
>
> None.
>
>> Another cl-lib question is the type of clause usable with
>> `cl-loop' that are described like this in the docstring:
>
> I wouldn't know, I never use `cl-loop`.

OK, thanks!

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-21  3:34                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-21 17:21                       ` Leo Butler
@ 2021-07-22  8:16                       ` Tomas Hlavaty
  1 sibling, 0 replies; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-22  8:16 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Wed 21 Jul 2021 at 05:34, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> Wow, looks interesting! Testing now! ...
>
> YIKES!!!
>
> https://dataswamp.org/~incal/figures/emacs/framebuffer-draw-test.png

thanks for feedback, this works as expected

the test obviously draws squares with 2 color as gradients and one
random color part (which makes it more interesting).  You can also see
that emacs redrawn part of the buffer and unfortunatelly, there is no
hook where I could redraw the picture after that.



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-21 17:21                       ` Leo Butler
  2021-07-21 17:52                         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-22  8:26                         ` Tomas Hlavaty
  1 sibling, 0 replies; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-22  8:26 UTC (permalink / raw)
  To: Leo Butler, help-gnu-emacs

On Wed 21 Jul 2021 at 12:21, Leo Butler <leo.butler@umanitoba.ca> wrote:
> Emanuel Berg via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
> Here is an example done from a console:
> I did:
> M-x eval-buffer RET
> M-x framebuffer-screenshot RET
> M-! ppmtojpg ... > ...

thanks for feedback, it seems to work

i wonder if it would be desirable to call ppmtojpg or better ppmtopng
(hmm, there is no ppmtopng, why not? there seems to be ppmtogif)
automatically if installed.  or write it in pure emacs lisp.

> @Tomas: I am not sure why, but when I do the same thing in an xterm
> (in the same emacs session, but with a different client, obviously), I
> end up with this:

here you see the ppm file contents as emacs-framebuffer works only in
framebuffer so far.  i think that it should be possible to support xterm
too because w3m browser is able to show pictures even in xterm, but i
haven't got around to this use-case as i am mainly after eliminating gui
dependencies



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 21:48                         ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-21 19:17                           ` Leo Butler
@ 2021-07-22  8:37                           ` Tomas Hlavaty
  2021-07-22 13:21                             ` Stefan Monnier
  2021-07-23  1:30                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-31 23:31                           ` Tomas Hlavaty
  2 siblings, 2 replies; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-22  8:37 UTC (permalink / raw)
  To: Stefan Monnier, help-gnu-emacs

On Tue 20 Jul 2021 at 17:48, Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>>> -(require 'cl)
>>> +(require 'cl-lib)

thanks for explanation!

> In some future release the plan is to remove `cl` from Emacs itself,
> tho we may then create a GNU ELPA package for it.

When this happens, does it mean that my package will stop working unless
the user installs the cl package from elpa?



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-22  8:37                           ` Screenshots, frame shots straight from Emacs Tomas Hlavaty
@ 2021-07-22 13:21                             ` Stefan Monnier
  2021-07-22 18:19                               ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-31 23:32                               ` Tomas Hlavaty
  2021-07-23  1:30                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 2 replies; 62+ messages in thread
From: Stefan Monnier @ 2021-07-22 13:21 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Tomas Hlavaty [2021-07-22 10:37:41] wrote:
> On Tue 20 Jul 2021 at 17:48, Stefan Monnier via Users list for the GNU Emacs
> text editor <help-gnu-emacs@gnu.org> wrote:
>>>> -(require 'cl)
>>>> +(require 'cl-lib)
> thanks for explanation!
>> In some future release the plan is to remove `cl` from Emacs itself,
>> tho we may then create a GNU ELPA package for it.
> When this happens, does it mean that my package will stop working unless
> the user installs the cl package from elpa?

Yes.


        Stefan




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-22 13:21                             ` Stefan Monnier
@ 2021-07-22 18:19                               ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-23 11:38                                 ` Jean Louis
  2021-07-31 23:32                               ` Tomas Hlavaty
  1 sibling, 1 reply; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-22 18:19 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

>> When this happens, does it mean that my package will stop
>> working unless the user installs the cl package from elpa?
>
> Yes.

Don't do it, why?

Remember the rule, never move anything that is already in it's
right place!

cl-lib is great, I've used in 148 times :)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-06-23  9:31               ` Screenshots, frame shots straight from Emacs Jean Louis
  2021-06-25 22:04                 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-23  0:52                 ` Hongyi Zhao
  2021-07-23  1:35                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-23  5:51                   ` Jean Louis
  1 sibling, 2 replies; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-23  0:52 UTC (permalink / raw)
  To: Hongyi Zhao, Omar Polo, help-gnu-emacs

On Wed, Jun 23, 2021 at 5:33 PM Jean Louis <bugs@gnu.support> wrote:
>
> As you like screenshots, here is one way to generate Emacs frame shots
> straight from Emacs without using external programs:
>
> (defvar frameshot-directory "~/Media/Pictures/Screenshots/"
>   "Default directory for frame shots")
>
> (defvar frameshot-format 'png
>   "Default frame shot format, could be 'jpg or 'svg, inspect the
>   function `x-export-frames'")
>
> (defun frameshot ()
>   "Save Emacs frame as frame shot.
>
> Directory is determined by variable `frameshot-directory' and if
> not defined, it will be saved in the `$HOME' directory."
>   (interactive)
>   (let* ((image (x-export-frames nil (or frameshot-format 'png)))
>          (base-directory (or frameshot-directory (getenv "HOME")))
>          (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
>          (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
>     (make-directory directory t)
>     (with-temp-file file
>       (insert image))
>     (find-file directory)
>     (message "Frame shot saved as `%s'" file)))

Thank you very much for your courtesy. I like screenshot is due to its
intuitive and simplicity compared to wording in many scenarios. Below
is some additional requirements I want to have with a decent
screenshot method:

1. Have the delay feature, so that I can do some operations before the
screenshot is captured, say, click on mouse button, open a dropdown
menu, and so on.
2. Have the post-processing feature, which can be used for some touch
ups on the generated screenshot subsequently.

I am not sure whether the recommended method here has these characteristics.

Best,
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-22  8:37                           ` Screenshots, frame shots straight from Emacs Tomas Hlavaty
  2021-07-22 13:21                             ` Stefan Monnier
@ 2021-07-23  1:30                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-23  1:30 UTC (permalink / raw)
  To: help-gnu-emacs

Tomas Hlavaty wrote:

> When this happens, does it mean that my package will stop
> working unless the user installs the cl package from elpa?

If you do,

  ;; Package-Requires: ((cl-lib "1.0"))

as in, e.g. [1] - if you do that and then issue the install
command for your package, won't it get the cl-lib
automatically? Because if it doesn't, how can it even work?

Or doesn't it work between the MELPA to ELPAs or
anything else?

[1] https://dataswamp.org/~incal/emacs-init/buc.el

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23  0:52                 ` Hongyi Zhao
@ 2021-07-23  1:35                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-23  1:55                     ` Hongyi Zhao
  2021-07-23  5:51                   ` Jean Louis
  1 sibling, 1 reply; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-23  1:35 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> Thank you very much for your courtesy. I like screenshot is
> due to its intuitive and simplicity compared to wording in
> many scenarios.

Screenshots are awesome to convey a lot of things but as for
"wording" it is an acquired skill to describe a tech problem
or situation and a large part of that is to know what details
are likely to be relevant and then present them and only them
in a way that communicates the situation or what has happened.

Taking a huge photo of the whole screen is maybe fast and fun
but it does a worse job at narrowing down the problem, as there
is so much unrelated material, even in a virtual console or
terminal emulator mode.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23  1:35                   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-23  1:55                     ` Hongyi Zhao
  0 siblings, 0 replies; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-23  1:55 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Fri, Jul 23, 2021 at 9:40 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > Thank you very much for your courtesy. I like screenshot is
> > due to its intuitive and simplicity compared to wording in
> > many scenarios.
>
> Screenshots are awesome to convey a lot of things but as for
> "wording" it is an acquired skill to describe a tech problem
> or situation and a large part of that is to know what details
> are likely to be relevant and then present them and only them
> in a way that communicates the situation or what has happened.
>
> Taking a huge photo of the whole screen is maybe fast and fun
> but it does a worse job at narrowing down the problem, as there
> is so much unrelated material, even in a virtual console or
> terminal emulator mode.

So, I think the following way is a compromise and complementary approaches:

1. If wording it enough, that's OK.
2. If not, use a screenshot with appropriate
comment/sketch/post-processing on it to avoid off-topic understanding.

I really want to have the feature of 2. supplied by native Emacs (or
with the helps of some 3-rd packages, say, the ones on MELPA), but I
still can't figure out the solution.

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23  0:52                 ` Hongyi Zhao
  2021-07-23  1:35                   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-23  5:51                   ` Jean Louis
  2021-07-23  8:56                     ` Hongyi Zhao
  2021-07-23  9:16                     ` Hongyi Zhao
  1 sibling, 2 replies; 62+ messages in thread
From: Jean Louis @ 2021-07-23  5:51 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs, Omar Polo

* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 03:53]:
> 1. Have the delay feature, so that I can do some operations before the
> screenshot is captured, say, click on mouse button, open a dropdown
> menu, and so on.

This improved function will allow that you invoke for example:

C-5 M-x frameshot to delay for 5 seconds. But this Emacs function I
think will not allow to get the screenshot of the dropdown, maybe it
requires using threads, now I don't know how to do it within Emacs.

(defun frameshot (&optional prefix)
  "Save Emacs frame as frame shot.

Directory is determined by variable `frameshot-directory' and if
not defined, it will be saved in the `$HOME' directory."
  (interactive "p")
  (let ((delay (or prefix 0)))
    (run-with-timer 
     delay nil
     (lambda ()
       (let* ((image (x-export-frames nil (or frameshot-format 'png)))
	      (base-directory (or frameshot-directory (getenv "HOME")))
	      (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
	      (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
	 (make-directory directory t)
	 (with-temp-file file
	   (insert image))
	 (find-file directory)
	 (message "Frame shot saved as `%s'" file))))))

To capture all screen I am using this external Common Lisp script,
that invokes maim:

#!/usr/bin/clisp

(load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.lisp")

(defparameter *image-capture-program* "maim")
(defparameter *image-type* ".png")
(defparameter *image-directory* "/home/data1/protected/Media/Pictures/Screenshots")

(let* ((filename (concatenate 'string (timestamp-filename) *image-type*))
       (year (substring filename 0 4))
       (month (substring filename 5 7))
       (date (substring filename 0 10))
       (directory (concatenate 'string *image-directory* "/" year "/" month "/" date "/"))
       (command (concatenate 'string *image-capture-program* " \"" directory filename "\""))
       (rox-command (concatenate 'string "rox " directory)))
  (print directory)
  (print command)
  (ensure-directories-exist directory)
  (shell command)
  (shell rox-command))

You could install either `maim' or other system screenshot program and
use that one.

> 2. Have the post-processing feature, which can be used for some
> touch I am not sure whether the recommended method here has these
> characteristics.

I am often using few simple functions for processing that invoke
ImageMagick:

(defvar *image-default-resize-size* 1536)
(defvar *image-resize-sizes* '())

;; This function optimizes image for websites to reach the optimum
;; Internet speed

(defun optimize-image-jpg (file &optional quality)
  "Optimizes the JPG image with quality 70%"
  (if (rcd-which-list '("mogrify"))
      (let ((extension (file-name-extension file))
	    (quality (or quality "70")))
	(when (string-match "\\(?:\\(?:jpe?\\|pn\\)g\\)" (downcase extension))
	    (message "Optimizing `%s'" file)
	    (call-process "mogrify" nil  "-sampling-factor" "4:2:0" "-strip" "-interlace" "JPEG" "-colorspace" "RGB" "-format" "jpg" "-quality" quality file)
	    (message "Optimizing FINISHED for `%s'" file)))
    (rcd-warning-message "RCD ERROR: `mogrify' not found in $PATH")))

;; Mark files in Dired, optimize images

(defun optimize-jpg-images-dired ()
  "Optimizes JPG images inside of Dired"
  (interactive)
  (let ((files (dired-get-marked-files)))
    (while files
      (optimize-image-jpg (pop files)))
    (revert-buffer)))

(defun image-resize (file &optional size)
  "Resizes the JPG image with default size"
  (if (rcd-which-list '("mogrify"))
      (let ((extension (file-name-extension file)))
	(when (or (equal (downcase extension) "jpg")
		  (equal (downcase extension) "png"))
	  (let* ((file (shell-double-quote file))
		 (command (format "mogrify -resize %s \"%s\"" size file)))
	    (message command)
	    (call-process-shell-command command))))
    (rcd-warning-message "RCD ERROR: `mogrify' not found in `$PATH'")))

;; Mark files in dired, resize images

(defun image-resize-dired ()
  "Resizes images"
  (interactive)
  (let ((files (dired-get-marked-files))
	(size (read-number "Size: " *image-default-resize-size* '*image-resize-sizes*)))
    (while files
      (image-resize (pop files) size))
    (revert-buffer)))

If you know what exactly you wish to do to images then it is possible
to use same methods and invoke ImageMagick processing.




-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23  5:51                   ` Jean Louis
@ 2021-07-23  8:56                     ` Hongyi Zhao
  2021-07-23 10:28                       ` Hongyi Zhao
  2021-07-23 11:04                       ` Jean Louis
  2021-07-23  9:16                     ` Hongyi Zhao
  1 sibling, 2 replies; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-23  8:56 UTC (permalink / raw)
  To: Hongyi Zhao, Omar Polo, help-gnu-emacs

On Fri, Jul 23, 2021 at 1:55 PM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 03:53]:
> > 1. Have the delay feature, so that I can do some operations before the
> > screenshot is captured, say, click on mouse button, open a dropdown
> > menu, and so on.
>
> This improved function will allow that you invoke for example:
>
> C-5 M-x frameshot to delay for 5 seconds.

Good idea.

> But this Emacs function I think will not allow to get the screenshot of the dropdown, maybe it
> requires using threads, now I don't know how to do it within Emacs.

Anyway, thank you very much for your help.

> (defun frameshot (&optional prefix)
>   "Save Emacs frame as frame shot.
>
> Directory is determined by variable `frameshot-directory' and if
> not defined, it will be saved in the `$HOME' directory."
>   (interactive "p")
>   (let ((delay (or prefix 0)))
>     (run-with-timer
>      delay nil
>      (lambda ()
>        (let* ((image (x-export-frames nil (or frameshot-format 'png)))
>               (base-directory (or frameshot-directory (getenv "HOME")))
>               (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
>               (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
>          (make-directory directory t)
>          (with-temp-file file
>            (insert image))
>          (find-file directory)
>          (message "Frame shot saved as `%s'" file))))))
>
> To capture all screen I am using this external Common Lisp script,
> that invokes maim:
>
> #!/usr/bin/clisp
>
> (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.lisp")
>
> (defparameter *image-capture-program* "maim")
> (defparameter *image-type* ".png")
> (defparameter *image-directory* "/home/data1/protected/Media/Pictures/Screenshots")
>
> (let* ((filename (concatenate 'string (timestamp-filename) *image-type*))
>        (year (substring filename 0 4))
>        (month (substring filename 5 7))
>        (date (substring filename 0 10))
>        (directory (concatenate 'string *image-directory* "/" year "/" month "/" date "/"))
>        (command (concatenate 'string *image-capture-program* " \"" directory filename "\""))
>        (rox-command (concatenate 'string "rox " directory)))
>   (print directory)
>   (print command)
>   (ensure-directories-exist directory)
>   (shell command)
>   (shell rox-command))
>
> You could install either `maim' or other system screenshot program and
> use that one.

Thank you for recommending `maim' to me. From its official description
[1], it can be seen as an improved scrot, which is the one used by me
now.

[1] https://github.com/naelstrof/maim

> > 2. Have the post-processing feature, which can be used for some
> > touch I am not sure whether the recommended method here has these
> > characteristics.
>
> I am often using few simple functions for processing that invoke
> ImageMagick:
>
> (defvar *image-default-resize-size* 1536)
> (defvar *image-resize-sizes* '())
>
> ;; This function optimizes image for websites to reach the optimum
> ;; Internet speed
>
> (defun optimize-image-jpg (file &optional quality)
>   "Optimizes the JPG image with quality 70%"
>   (if (rcd-which-list '("mogrify"))
>       (let ((extension (file-name-extension file))
>             (quality (or quality "70")))
>         (when (string-match "\\(?:\\(?:jpe?\\|pn\\)g\\)" (downcase extension))
>             (message "Optimizing `%s'" file)
>             (call-process "mogrify" nil  "-sampling-factor" "4:2:0" "-strip" "-interlace" "JPEG" "-colorspace" "RGB" "-format" "jpg" "-quality" quality file)
>             (message "Optimizing FINISHED for `%s'" file)))
>     (rcd-warning-message "RCD ERROR: `mogrify' not found in $PATH")))
>
> ;; Mark files in Dired, optimize images
>
> (defun optimize-jpg-images-dired ()
>   "Optimizes JPG images inside of Dired"
>   (interactive)
>   (let ((files (dired-get-marked-files)))
>     (while files
>       (optimize-image-jpg (pop files)))
>     (revert-buffer)))
>
> (defun image-resize (file &optional size)
>   "Resizes the JPG image with default size"
>   (if (rcd-which-list '("mogrify"))
>       (let ((extension (file-name-extension file)))
>         (when (or (equal (downcase extension) "jpg")
>                   (equal (downcase extension) "png"))
>           (let* ((file (shell-double-quote file))
>                  (command (format "mogrify -resize %s \"%s\"" size file)))
>             (message command)
>             (call-process-shell-command command))))
>     (rcd-warning-message "RCD ERROR: `mogrify' not found in `$PATH'")))
>
> ;; Mark files in dired, resize images
>
> (defun image-resize-dired ()
>   "Resizes images"
>   (interactive)
>   (let ((files (dired-get-marked-files))
>         (size (read-number "Size: " *image-default-resize-size* '*image-resize-sizes*)))
>     (while files
>       (image-resize (pop files) size))
>     (revert-buffer)))
>
> If you know what exactly you wish to do to images then it is possible
> to use same methods and invoke ImageMagick processing.

Other possible processing includes highlighting some regions with
square or circle,  adding some text comments, and drawing some lines
or arrows, and so on. I'm not sure whether all these trivial
operations can be done by the method similar to the above.

Regards,
Hongyi



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23  5:51                   ` Jean Louis
  2021-07-23  8:56                     ` Hongyi Zhao
@ 2021-07-23  9:16                     ` Hongyi Zhao
  1 sibling, 0 replies; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-23  9:16 UTC (permalink / raw)
  To: Hongyi Zhao, Omar Polo, help-gnu-emacs

On Fri, Jul 23, 2021 at 1:55 PM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 03:53]:
> > 1. Have the delay feature, so that I can do some operations before the
> > screenshot is captured, say, click on mouse button, open a dropdown
> > menu, and so on.
>
> This improved function will allow that you invoke for example:
>
> C-5 M-x frameshot to delay for 5 seconds. But this Emacs function I
> think will not allow to get the screenshot of the dropdown, maybe it
> requires using threads, now I don't know how to do it within Emacs.

Based on the comment here [1], I find the following simple method to
capture a drop-down menu:


Install the imagemagick package, then issue the following command on a terminal:

$ sleep 10; import -window root /tmp/screenshot.png

In the next 10 seconds change your active window, open the dropdown
menu and wait. You will likely need to crop your screenshot
afterwards.


[1] https://askubuntu.com/questions/584778/how-to-capture-a-drop-down-menu

Best,
Hongyi



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23  8:56                     ` Hongyi Zhao
@ 2021-07-23 10:28                       ` Hongyi Zhao
  2021-07-23 10:32                         ` Hongyi Zhao
  2021-07-23 11:04                       ` Jean Louis
  1 sibling, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-23 10:28 UTC (permalink / raw)
  To: Hongyi Zhao, Omar Polo, help-gnu-emacs

On Fri, Jul 23, 2021 at 4:56 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Fri, Jul 23, 2021 at 1:55 PM Jean Louis <bugs@gnu.support> wrote:
> >
> > * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 03:53]:
> > > 1. Have the delay feature, so that I can do some operations before the
> > > screenshot is captured, say, click on mouse button, open a dropdown
> > > menu, and so on.
> >
> > This improved function will allow that you invoke for example:
> >
> > C-5 M-x frameshot to delay for 5 seconds.
>
> Good idea.
>
> > But this Emacs function I think will not allow to get the screenshot of the dropdown, maybe it
> > requires using threads, now I don't know how to do it within Emacs.
>
> Anyway, thank you very much for your help.
>
> > (defun frameshot (&optional prefix)
> >   "Save Emacs frame as frame shot.
> >
> > Directory is determined by variable `frameshot-directory' and if
> > not defined, it will be saved in the `$HOME' directory."
> >   (interactive "p")
> >   (let ((delay (or prefix 0)))
> >     (run-with-timer
> >      delay nil
> >      (lambda ()
> >        (let* ((image (x-export-frames nil (or frameshot-format 'png)))
> >               (base-directory (or frameshot-directory (getenv "HOME")))
> >               (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
> >               (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
> >          (make-directory directory t)
> >          (with-temp-file file
> >            (insert image))
> >          (find-file directory)
> >          (message "Frame shot saved as `%s'" file))))))
> >
> > To capture all screen I am using this external Common Lisp script,
> > that invokes maim:
> >
> > #!/usr/bin/clisp
> >
> > (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.lisp")
> >
> > (defparameter *image-capture-program* "maim")
> > (defparameter *image-type* ".png")
> > (defparameter *image-directory* "/home/data1/protected/Media/Pictures/Screenshots")
> >
> > (let* ((filename (concatenate 'string (timestamp-filename) *image-type*))
> >        (year (substring filename 0 4))
> >        (month (substring filename 5 7))
> >        (date (substring filename 0 10))
> >        (directory (concatenate 'string *image-directory* "/" year "/" month "/" date "/"))
> >        (command (concatenate 'string *image-capture-program* " \"" directory filename "\""))
> >        (rox-command (concatenate 'string "rox " directory)))
> >   (print directory)
> >   (print command)
> >   (ensure-directories-exist directory)
> >   (shell command)
> >   (shell rox-command))
> >
> > You could install either `maim' or other system screenshot program and
> > use that one.
>
> Thank you for recommending `maim' to me. From its official description
> [1], it can be seen as an improved scrot, which is the one used by me
> now.
>
> [1] https://github.com/naelstrof/maim

Further comment, based on my tries and the discussions here [1], the
imagemagick and shutter [2] are more powerful and versatile than maim
and scrot.

[1] https://askubuntu.com/questions/584778/how-to-capture-a-drop-down-menu
[2] https://github.com/shutter-project/shutter


> > > 2. Have the post-processing feature, which can be used for some
> > > touch I am not sure whether the recommended method here has these
> > > characteristics.
> >
> > I am often using few simple functions for processing that invoke
> > ImageMagick:
> >
> > (defvar *image-default-resize-size* 1536)
> > (defvar *image-resize-sizes* '())
> >
> > ;; This function optimizes image for websites to reach the optimum
> > ;; Internet speed
> >
> > (defun optimize-image-jpg (file &optional quality)
> >   "Optimizes the JPG image with quality 70%"
> >   (if (rcd-which-list '("mogrify"))
> >       (let ((extension (file-name-extension file))
> >             (quality (or quality "70")))
> >         (when (string-match "\\(?:\\(?:jpe?\\|pn\\)g\\)" (downcase extension))
> >             (message "Optimizing `%s'" file)
> >             (call-process "mogrify" nil  "-sampling-factor" "4:2:0" "-strip" "-interlace" "JPEG" "-colorspace" "RGB" "-format" "jpg" "-quality" quality file)
> >             (message "Optimizing FINISHED for `%s'" file)))
> >     (rcd-warning-message "RCD ERROR: `mogrify' not found in $PATH")))
> >
> > ;; Mark files in Dired, optimize images
> >
> > (defun optimize-jpg-images-dired ()
> >   "Optimizes JPG images inside of Dired"
> >   (interactive)
> >   (let ((files (dired-get-marked-files)))
> >     (while files
> >       (optimize-image-jpg (pop files)))
> >     (revert-buffer)))
> >
> > (defun image-resize (file &optional size)
> >   "Resizes the JPG image with default size"
> >   (if (rcd-which-list '("mogrify"))
> >       (let ((extension (file-name-extension file)))
> >         (when (or (equal (downcase extension) "jpg")
> >                   (equal (downcase extension) "png"))
> >           (let* ((file (shell-double-quote file))
> >                  (command (format "mogrify -resize %s \"%s\"" size file)))
> >             (message command)
> >             (call-process-shell-command command))))
> >     (rcd-warning-message "RCD ERROR: `mogrify' not found in `$PATH'")))
> >
> > ;; Mark files in dired, resize images
> >
> > (defun image-resize-dired ()
> >   "Resizes images"
> >   (interactive)
> >   (let ((files (dired-get-marked-files))
> >         (size (read-number "Size: " *image-default-resize-size* '*image-resize-sizes*)))
> >     (while files
> >       (image-resize (pop files) size))
> >     (revert-buffer)))
> >
> > If you know what exactly you wish to do to images then it is possible
> > to use same methods and invoke ImageMagick processing.
>
> Other possible processing includes highlighting some regions with
> square or circle,  adding some text comments, and drawing some lines
> or arrows, and so on. I'm not sure whether all these trivial
> operations can be done by the method similar to the above.
>
> Regards,
> Hongyi



-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23 10:28                       ` Hongyi Zhao
@ 2021-07-23 10:32                         ` Hongyi Zhao
  0 siblings, 0 replies; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-23 10:32 UTC (permalink / raw)
  To: Hongyi Zhao, Omar Polo, help-gnu-emacs

On Fri, Jul 23, 2021 at 6:28 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Fri, Jul 23, 2021 at 4:56 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> >
> > On Fri, Jul 23, 2021 at 1:55 PM Jean Louis <bugs@gnu.support> wrote:
> > >
> > > * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 03:53]:
> > > > 1. Have the delay feature, so that I can do some operations before the
> > > > screenshot is captured, say, click on mouse button, open a dropdown
> > > > menu, and so on.
> > >
> > > This improved function will allow that you invoke for example:
> > >
> > > C-5 M-x frameshot to delay for 5 seconds.
> >
> > Good idea.
> >
> > > But this Emacs function I think will not allow to get the screenshot of the dropdown, maybe it
> > > requires using threads, now I don't know how to do it within Emacs.
> >
> > Anyway, thank you very much for your help.
> >
> > > (defun frameshot (&optional prefix)
> > >   "Save Emacs frame as frame shot.
> > >
> > > Directory is determined by variable `frameshot-directory' and if
> > > not defined, it will be saved in the `$HOME' directory."
> > >   (interactive "p")
> > >   (let ((delay (or prefix 0)))
> > >     (run-with-timer
> > >      delay nil
> > >      (lambda ()
> > >        (let* ((image (x-export-frames nil (or frameshot-format 'png)))
> > >               (base-directory (or frameshot-directory (getenv "HOME")))
> > >               (directory (concat (file-name-as-directory base-directory) (format-time-string "%Y/%m/%Y-%m-%d/")))
> > >               (file (concat directory (format-time-string "Screenshot-%Y-%m-%d-%T.") (symbol-name frameshot-format))))
> > >          (make-directory directory t)
> > >          (with-temp-file file
> > >            (insert image))
> > >          (find-file directory)
> > >          (message "Frame shot saved as `%s'" file))))))
> > >
> > > To capture all screen I am using this external Common Lisp script,
> > > that invokes maim:
> > >
> > > #!/usr/bin/clisp
> > >
> > > (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.lisp")
> > >
> > > (defparameter *image-capture-program* "maim")
> > > (defparameter *image-type* ".png")
> > > (defparameter *image-directory* "/home/data1/protected/Media/Pictures/Screenshots")
> > >
> > > (let* ((filename (concatenate 'string (timestamp-filename) *image-type*))
> > >        (year (substring filename 0 4))
> > >        (month (substring filename 5 7))
> > >        (date (substring filename 0 10))
> > >        (directory (concatenate 'string *image-directory* "/" year "/" month "/" date "/"))
> > >        (command (concatenate 'string *image-capture-program* " \"" directory filename "\""))
> > >        (rox-command (concatenate 'string "rox " directory)))
> > >   (print directory)
> > >   (print command)
> > >   (ensure-directories-exist directory)
> > >   (shell command)
> > >   (shell rox-command))
> > >
> > > You could install either `maim' or other system screenshot program and
> > > use that one.
> >
> > Thank you for recommending `maim' to me. From its official description
> > [1], it can be seen as an improved scrot, which is the one used by me
> > now.
> >
> > [1] https://github.com/naelstrof/maim
>
> Further comment, based on my tries and the discussions here [1], the
> imagemagick and shutter [2] are more powerful and versatile than maim
> and scrot.
>
> [1] https://askubuntu.com/questions/584778/how-to-capture-a-drop-down-menu
> [2] https://github.com/shutter-project/shutter

So I suggest don't use tools like maim and scrot if imagemagick or
shutter can be directly invoked from within Emacs.

Hongyi



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23  8:56                     ` Hongyi Zhao
  2021-07-23 10:28                       ` Hongyi Zhao
@ 2021-07-23 11:04                       ` Jean Louis
  2021-07-23 11:41                         ` Hongyi Zhao
  1 sibling, 1 reply; 62+ messages in thread
From: Jean Louis @ 2021-07-23 11:04 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs, Omar Polo

[-- Attachment #1: Type: text/plain, Size: 959 bytes --]

* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 11:57]:
> Other possible processing includes highlighting some regions with
> square or circle,  adding some text comments, and drawing some lines
> or arrows, and so on. I'm not sure whether all these trivial
> operations can be done by the method similar to the above.

If you wish to make a PDF file with annotations or otherwise annotate
other PDF files, I am recommending this application:

Description     : Handwriting notetaking software with PDF annotation support
URL             : https://github.com/xournalpp/xournalpp

Now when you make a screenshot you can then open up Xournalapp and
import the image and make your annotations on the image, save as
PDF. Similar can be done with graphics editors such as GIMP.

See example in attachment.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/

[-- Attachment #2: 2021-07-23-Note-13-59.pdf --]
[-- Type: application/pdf, Size: 85419 bytes --]

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-22 18:19                               ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-23 11:38                                 ` Jean Louis
  2021-08-01  1:38                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 62+ messages in thread
From: Jean Louis @ 2021-07-23 11:38 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-07-22 21:21]:
> Stefan Monnier wrote:
> 
> >> When this happens, does it mean that my package will stop
> >> working unless the user installs the cl package from elpa?
> >
> > Yes.
> 
> Don't do it, why?
> 
> Remember the rule, never move anything that is already in it's
> right place!
> 
> cl-lib is great, I've used in 148 times :)

I like Common Lisp, but not "CL" in Emacs space and everything still
works without it.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23 11:04                       ` Jean Louis
@ 2021-07-23 11:41                         ` Hongyi Zhao
  2021-07-24 15:22                           ` Hongyi Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-23 11:41 UTC (permalink / raw)
  To: Hongyi Zhao, Omar Polo, help-gnu-emacs

On Fri, Jul 23, 2021 at 7:05 PM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 11:57]:
> > Other possible processing includes highlighting some regions with
> > square or circle,  adding some text comments, and drawing some lines
> > or arrows, and so on. I'm not sure whether all these trivial
> > operations can be done by the method similar to the above.
>
> If you wish to make a PDF file with annotations or otherwise annotate
> other PDF files, I am recommending this application:
>
> Description     : Handwriting notetaking software with PDF annotation support
> URL             : https://github.com/xournalpp/xournalpp
>
> Now when you make a screenshot you can then open up Xournalapp and
> import the image and make your annotations on the image, save as
> PDF. Similar can be done with graphics editors such as GIMP.

GIMP is wonderful, but for this situation, it is a bit too cumbersome.

> See example in attachment.

Thank you for telling me this wonderful tool. As far as I know, I
summarize several tools discussed and suggested here till now:

[1] https://github.com/ImageMagick/ImageMagick
[2] https://github.com/xournalpp/xournalpp
[3] https://github.com/ksnip/ksnip
[4] https://github.com/shutter-project/shutter

Best regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23 11:41                         ` Hongyi Zhao
@ 2021-07-24 15:22                           ` Hongyi Zhao
  0 siblings, 0 replies; 62+ messages in thread
From: Hongyi Zhao @ 2021-07-24 15:22 UTC (permalink / raw)
  To: Hongyi Zhao, Omar Polo, help-gnu-emacs

On Fri, Jul 23, 2021 at 7:41 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Fri, Jul 23, 2021 at 7:05 PM Jean Louis <bugs@gnu.support> wrote:
> >
> > * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-23 11:57]:
> > > Other possible processing includes highlighting some regions with
> > > square or circle,  adding some text comments, and drawing some lines
> > > or arrows, and so on. I'm not sure whether all these trivial
> > > operations can be done by the method similar to the above.
> >
> > If you wish to make a PDF file with annotations or otherwise annotate
> > other PDF files, I am recommending this application:
> >
> > Description     : Handwriting notetaking software with PDF annotation support
> > URL             : https://github.com/xournalpp/xournalpp
> >
> > Now when you make a screenshot you can then open up Xournalapp and
> > import the image and make your annotations on the image, save as
> > PDF. Similar can be done with graphics editors such as GIMP.
>
> GIMP is wonderful, but for this situation, it is a bit too cumbersome.
>
> > See example in attachment.
>
> Thank you for telling me this wonderful tool. As far as I know, I
> summarize several tools discussed and suggested here till now:
>
> [1] https://github.com/ImageMagick/ImageMagick
> [2] https://github.com/xournalpp/xournalpp
> [3] https://github.com/ksnip/ksnip

I no longer recommend using ksnip based on my preliminary use experience.

> [4] https://github.com/shutter-project/shutter

For shutter compilation from its git master source code, see [1].

[1] https://github.com/shutter-project/shutter/issues/370#issuecomment-886063326

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 20:50                           ` Tomas Hlavaty
@ 2021-07-31 23:25                             ` Tomas Hlavaty
  2021-08-01  2:16                               ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-08-01  2:59                               ` Eduardo Ochs
  0 siblings, 2 replies; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-31 23:25 UTC (permalink / raw)
  To: Leo Butler; +Cc: help-gnu-emacs

On Tue 20 Jul 2021 at 22:50, Tomas Hlavaty <tom@logand.com> wrote:
> I'll push the fixes at the end of this week when I have better
> internet connection.

done

see https://logand.com/sw/emacs-framebuffer/

or clone:

• (eepitch-shell)
• (eepitch-kill)
• (eepitch-shell)
cd /tmp
rm -r /tmp/emacs-framebuffer
git clone https://logand.com/git/emacs-framebuffer.git
cd /tmp/emacs-framebuffer
PAGER= git log -p | head -n 20



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-20 21:48                         ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-21 19:17                           ` Leo Butler
  2021-07-22  8:37                           ` Screenshots, frame shots straight from Emacs Tomas Hlavaty
@ 2021-07-31 23:31                           ` Tomas Hlavaty
  2021-08-01 14:19                             ` Stefan Monnier
  2 siblings, 1 reply; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-31 23:31 UTC (permalink / raw)
  To: Stefan Monnier, help-gnu-emacs

On Tue 20 Jul 2021 at 17:48, Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> But it does require code changes (mostly adding `cl-` prefixes).

is there a way to get a list of those cases in a compilation unit (el
file), e.g. byte-compilation warnings which i could fix after switching
from require 'cl to require 'cl-lib?



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-22 13:21                             ` Stefan Monnier
  2021-07-22 18:19                               ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-31 23:32                               ` Tomas Hlavaty
  1 sibling, 0 replies; 62+ messages in thread
From: Tomas Hlavaty @ 2021-07-31 23:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

On Thu 22 Jul 2021 at 09:21, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Tomas Hlavaty [2021-07-22 10:37:41] wrote:
>> On Tue 20 Jul 2021 at 17:48, Stefan Monnier via Users list for the GNU Emacs
>> text editor <help-gnu-emacs@gnu.org> wrote:
>>>>> -(require 'cl)
>>>>> +(require 'cl-lib)
>> thanks for explanation!
>>> In some future release the plan is to remove `cl` from Emacs itself,
>>> tho we may then create a GNU ELPA package for it.
>> When this happens, does it mean that my package will stop working unless
>> the user installs the cl package from elpa?
>
> Yes.

ok, thanks for clarification



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-23 11:38                                 ` Jean Louis
@ 2021-08-01  1:38                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-01  1:38 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> I like Common Lisp, but not "CL" in Emacs space and
> everything still works without it.

The Common Lisp extensions for Emacs only works if you use
cl-lib.el.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-31 23:25                             ` Tomas Hlavaty
@ 2021-08-01  2:16                               ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-08-01  6:40                                 ` Tomas Hlavaty
  2021-08-01  2:59                               ` Eduardo Ochs
  1 sibling, 1 reply; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-01  2:16 UTC (permalink / raw)
  To: help-gnu-emacs

Tomas Hlavaty wrote:

>> I'll push the fixes at the end of this week when I have
>> better internet connection.
>
> done
>
> see https://logand.com/sw/emacs-framebuffer/

How and why did you get the idea for this software?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-31 23:25                             ` Tomas Hlavaty
  2021-08-01  2:16                               ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-01  2:59                               ` Eduardo Ochs
  1 sibling, 0 replies; 62+ messages in thread
From: Eduardo Ochs @ 2021-08-01  2:59 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs, Leo Butler

By the way, here is what I use to take screenshots...
This is a "5-minute hack" built on top of eev, following the style
that I explained here:

  http://angg.twu.net/emacsconf2020.html
  http://angg.twu.net/.emacs.videos.html#eev2020

Here is its only defun (and a defalias):



;; Skel: (find-find-links-links-new "sshot" "nsecs" "")
;; Test: (find-sshot-links)
;;
(defun find-sshot-links (&optional nsecs &rest pos-spec-list)
"Visit a temporary buffer containing hyperlinks taking a screenshot."
  (interactive)
  (setq nsecs (or nsecs "5"))
  (setq nsecs (or nsecs "{nsecs}"))
  (apply
   'find-elinks
   `((find-sshot-links ,nsecs ,@pos-spec-list)
     (find-sshot-links "{nsecs}")
     ;; Convention: the first sexp always regenerates the buffer.
     (find-efunction 'find-sshot-links)
     ""
     ,(ee-template0 "\
\(eev                        \"sleep {nsecs} && scrot
--select /tmp/sshot.png\")
\(find-bgprocess '(\"sh\" \"-c\" \"sleep {nsecs} && scrot
--select /tmp/sshot.png\"))
\(find-bgprocess '(\"sh\" \"-c\" \"sleep {nsecs} && scrot --border
--select /tmp/sshot.png\"))
\(find-bgprocess \"xzgv /tmp/sshot.png\")
\(find-bgprocess \"gimp /tmp/sshot.png\")
\(find-fline   \"/tmp/\" \"sshot.png\")
\(find-fline   \"/tmp/sshot.png\")
\(imgbb-upload \"/tmp/sshot.png\")
")
     )
   pos-spec-list))

(defalias 'sshot 'find-sshot-links)



To take a screenshot I type M-x sshot, and I then get a temporary
buffer containing this:

  # (find-sshot-links "5")
  # (find-sshot-links "{nsecs}")
  # (find-efunction 'find-sshot-links)

  (eev                        "sleep 5 && scrot          --select
/tmp/sshot.png")
  (find-bgprocess '("sh" "-c" "sleep 5 && scrot          --select
/tmp/sshot.png"))
  (find-bgprocess '("sh" "-c" "sleep 5 && scrot --border --select
/tmp/sshot.png"))
  (find-bgprocess "xzgv /tmp/sshot.png")
  (find-bgprocess "gimp /tmp/sshot.png")
  (find-fline   "/tmp/" "sshot.png")
  (find-fline   "/tmp/sshot.png")
  (xz           "/tmp/sshot.png")
  (imgbb-upload "/tmp/sshot.png")

The `find-bgprocess'es run scrot after a delay of 5 seconds... so I
have 5 seconds after executing the `find-bgprocess' to put the right
window (emacs-y or not) in the foreground, and then click on it in the
way that scrot or scrot --border expects.

I need to adapt that to include lines that run the other programs that
were suggested in this thread, but I was too busy in these last
weeks... =(

  Cheers,
    Eduardo Ochs
    http://angg.twu.net/#eev



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-08-01  2:16                               ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-01  6:40                                 ` Tomas Hlavaty
  2021-08-01  7:16                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 62+ messages in thread
From: Tomas Hlavaty @ 2021-08-01  6:40 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Sun 01 Aug 2021 at 04:16, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> Tomas Hlavaty wrote:
>> see https://logand.com/sw/emacs-framebuffer/
>
> How and why did you get the idea for this software?

Many things in Emacs do not work without GUI.  This fixes the most
important cases for me.



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-08-01  6:40                                 ` Tomas Hlavaty
@ 2021-08-01  7:16                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-08-01  7:42                                     ` Tomas Hlavaty
  0 siblings, 1 reply; 62+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-01  7:16 UTC (permalink / raw)
  To: help-gnu-emacs

Tomas Hlavaty wrote:

> Many things in Emacs do not work without GUI. This fixes the
> most important cases for me.

So you don't have to use X?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-08-01  7:16                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-01  7:42                                     ` Tomas Hlavaty
  2021-08-02 13:57                                       ` Hongyi Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Tomas Hlavaty @ 2021-08-01  7:42 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Sun 01 Aug 2021 at 09:16, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> Tomas Hlavaty wrote:
>> Many things in Emacs do not work without GUI. This fixes the
>> most important cases for me.
> So you don't have to use X?

yes, X and all other current and future dependencies



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-07-31 23:31                           ` Tomas Hlavaty
@ 2021-08-01 14:19                             ` Stefan Monnier
  0 siblings, 0 replies; 62+ messages in thread
From: Stefan Monnier @ 2021-08-01 14:19 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Tomas Hlavaty [2021-08-01 01:31:30] wrote:
> On Tue 20 Jul 2021 at 17:48, Stefan Monnier via Users list for the GNU Emacs
> text editor <help-gnu-emacs@gnu.org> wrote:
>> But it does require code changes (mostly adding `cl-` prefixes).
>
> is there a way to get a list of those cases in a compilation unit (el
> file), e.g. byte-compilation warnings which i could fix after switching
> from require 'cl to require 'cl-lib?

The byte-compiler should indeed warn you about functions "not known to
be defined", listing things like `case`, `incf`, `first`, `loop`, ...
Tho sometimes instead you'll get a compilation error because the code
uses a macro whose arguments don't have a valid shape when interpreted
as expressions (as in `(destructuring-bind (a . b) foo bar)`).
Also sometimes you'll get warnings about functions "not known to be
defined" which are indeed not functions (e.g. with `(case foo (:plop
bar))` which will complain that `:plop` is not a known function) or
you'll get warnings about unknown variables like `return` or `when`
which are really keywords of the `loop` macro.


        Stefan




^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-08-01  7:42                                     ` Tomas Hlavaty
@ 2021-08-02 13:57                                       ` Hongyi Zhao
  2021-08-02 19:57                                         ` Tomas Hlavaty
  0 siblings, 1 reply; 62+ messages in thread
From: Hongyi Zhao @ 2021-08-02 13:57 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs, Emanuel Berg

On Sun, Aug 1, 2021 at 3:42 PM Tomas Hlavaty <tom@logand.com> wrote:
>
> On Sun 01 Aug 2021 at 09:16, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> > Tomas Hlavaty wrote:
> >> Many things in Emacs do not work without GUI. This fixes the
> >> most important cases for me.
> > So you don't have to use X?
>
> yes, X and all other current and future dependencies

It sounds wonderful. I try to clone you repo, but failed:

$ git clone https://logand.com/sw/emacs-framebuffer.git
Cloning into 'emacs-framebuffer'...
fatal: repository 'https://logand.com/sw/emacs-framebuffer.git/' not found

Why not put it on GitHub and also give some use cases?

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-08-02 13:57                                       ` Hongyi Zhao
@ 2021-08-02 19:57                                         ` Tomas Hlavaty
  2021-08-03  0:56                                           ` Hongyi Zhao
  0 siblings, 1 reply; 62+ messages in thread
From: Tomas Hlavaty @ 2021-08-02 19:57 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

On Mon 02 Aug 2021 at 21:57, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> It sounds wonderful. I try to clone you repo, but failed:
>
> $ git clone https://logand.com/sw/emacs-framebuffer.git
> Cloning into 'emacs-framebuffer'...
> fatal: repository 'https://logand.com/sw/emacs-framebuffer.git/' not found

you are using wrong url, try

git clone https://logand.com/git/emacs-framebuffer.git

I did write it correctly in id:87wnp62hhe.fsf@logand.com and it is also
correct in the sources.

Where did you find the wrong url?

> Why not put it on GitHub

because I do not want Microsoft Github

> and also give some use cases?

Agree that the documentation is rather sparse but it does say:

   Show images and documents in console using Linux framebuffer.

When you open an image or a document, it will simply display it.

What do you think I should write about?



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: Screenshots, frame shots straight from Emacs
  2021-08-02 19:57                                         ` Tomas Hlavaty
@ 2021-08-03  0:56                                           ` Hongyi Zhao
  0 siblings, 0 replies; 62+ messages in thread
From: Hongyi Zhao @ 2021-08-03  0:56 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

On Tue, Aug 3, 2021 at 3:57 AM Tomas Hlavaty <tom@logand.com> wrote:
>
> On Mon 02 Aug 2021 at 21:57, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> > It sounds wonderful. I try to clone you repo, but failed:
> >
> > $ git clone https://logand.com/sw/emacs-framebuffer.git
> > Cloning into 'emacs-framebuffer'...
> > fatal: repository 'https://logand.com/sw/emacs-framebuffer.git/' not found
>
> you are using wrong url, try
>
> git clone https://logand.com/git/emacs-framebuffer.git

Thank you, it does the trick.

> I did write it correctly in id:87wnp62hhe.fsf@logand.com and it is also
> correct in the sources.
>
> Where did you find the wrong url?

I am based on the following post by you:

;;;
> On Tue 20 Jul 2021 at 22:50, Tomas Hlavaty <tom@logand.com> wrote:
> > I'll push the fixes at the end of this week when I have better
> > internet connection.

> done
>
> see https://logand.com/sw/emacs-framebuffer/
;;;


> > Why not put it on GitHub
>
> because I do not want Microsoft Github

I understand. BTW, though Github is acquired by Microsoft, it's still
free and the top 1 free open source software development and version
control platform in the world.

> > and also give some use cases?
>
> Agree that the documentation is rather sparse but it does say:
>
>    Show images and documents in console using Linux framebuffer.
>
> When you open an image or a document, it will simply display it.

In the source, you says the following:

;;; - imagemagick to modify images and svg support

According to my experience, imagemagick will rasterize the vector
image. If you want to obtain a lossless vectorized image conversion
support, I suggest to use rsvg-convert and inkscape for svg support
[1]:

$ rsvg-convert -f pdf -o chemical_potential.pdf chemical_potential.svg
$ inkscape chemical_potential.svg --export-pdf=chemical_potential.pdf

> What do you think I should write about?

Thank you for your explanation. Let me give it a try and then
comment/feedback further.

[1] https://superuser.com/questions/381125/how-do-i-convert-an-svg-to-a-pdf-on-linux

Best
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2021-08-03  0:56 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19 13:57 The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code Hongyi Zhao
2021-06-19 14:48 ` Omar Polo
2021-06-19 15:40   ` Hongyi Zhao
2021-06-19 15:57     ` Omar Polo
2021-06-19 17:09       ` Hongyi Zhao
2021-06-23  7:48         ` Omar Polo
2021-06-23  8:56           ` Hongyi Zhao
2021-06-23  9:17             ` Hongyi Zhao
2021-06-23  9:31               ` Screenshots, frame shots straight from Emacs Jean Louis
2021-06-25 22:04                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-25 22:34                   ` Jean Louis
2021-06-25 23:55                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-28  6:47                       ` Jean Louis
2021-07-01 21:01                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-02 12:50                           ` Jean Louis
2021-07-02 15:34                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-20 11:36                   ` Tomas Hlavaty
2021-07-20 17:42                     ` Leo Butler
2021-07-20 19:44                       ` Tomas Hlavaty
2021-07-20 20:21                         ` Leo Butler
2021-07-20 20:50                           ` Tomas Hlavaty
2021-07-31 23:25                             ` Tomas Hlavaty
2021-08-01  2:16                               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-01  6:40                                 ` Tomas Hlavaty
2021-08-01  7:16                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-01  7:42                                     ` Tomas Hlavaty
2021-08-02 13:57                                       ` Hongyi Zhao
2021-08-02 19:57                                         ` Tomas Hlavaty
2021-08-03  0:56                                           ` Hongyi Zhao
2021-08-01  2:59                               ` Eduardo Ochs
2021-07-20 21:51                           ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-20 21:48                         ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-21 19:17                           ` Leo Butler
2021-07-21 20:05                             ` Stefan Monnier
2021-07-21 21:44                               ` cl-lib questions (was: Re: Screenshots, frame shots straight from Emacs) Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-21 21:59                                 ` cl-lib questions Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-21 22:09                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-22  8:37                           ` Screenshots, frame shots straight from Emacs Tomas Hlavaty
2021-07-22 13:21                             ` Stefan Monnier
2021-07-22 18:19                               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-23 11:38                                 ` Jean Louis
2021-08-01  1:38                                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-31 23:32                               ` Tomas Hlavaty
2021-07-23  1:30                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-31 23:31                           ` Tomas Hlavaty
2021-08-01 14:19                             ` Stefan Monnier
2021-07-21  3:34                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-21 17:21                       ` Leo Butler
2021-07-21 17:52                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-22  8:26                         ` Tomas Hlavaty
2021-07-22  8:16                       ` Tomas Hlavaty
2021-07-23  0:52                 ` Hongyi Zhao
2021-07-23  1:35                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-23  1:55                     ` Hongyi Zhao
2021-07-23  5:51                   ` Jean Louis
2021-07-23  8:56                     ` Hongyi Zhao
2021-07-23 10:28                       ` Hongyi Zhao
2021-07-23 10:32                         ` Hongyi Zhao
2021-07-23 11:04                       ` Jean Louis
2021-07-23 11:41                         ` Hongyi Zhao
2021-07-24 15:22                           ` Hongyi Zhao
2021-07-23  9:16                     ` Hongyi Zhao

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.