all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Elisp - Function returning a list
@ 2020-12-16  3:25 steve-humphreys
  2020-12-16  4:09 ` Jean Louis
  2020-12-16  4:13 ` Elisp - Function returning a list Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  3:25 UTC (permalink / raw)
  To: Help Gnu Emacs


I am having a go at making a function that returns a list of numbers, but need it interactive.
Unsure this is good

(defun typh-agenda-tgrd (tstr tend tskp)
   (interactive "n Start_Time: n End_Time: n Skip_Time: ")
   (number-sequence tstr tend tskp))




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

* Re: Elisp - Function returning a list
  2020-12-16  3:25 Elisp - Function returning a list steve-humphreys
@ 2020-12-16  4:09 ` Jean Louis
  2020-12-16  4:17   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16  4:30   ` Elisp - Function returning a list steve-humphreys
  2020-12-16  4:13 ` Elisp - Function returning a list Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 2 replies; 60+ messages in thread
From: Jean Louis @ 2020-12-16  4:09 UTC (permalink / raw)
  To: steve-humphreys; +Cc: Help Gnu Emacs

* steve-humphreys@gmx.com <steve-humphreys@gmx.com> [2020-12-16 06:27]:
> 
> I am having a go at making a function that returns a list of numbers, but need it interactive.
> Unsure this is good
> 
 (defun typh-agenda-tgrd (tstr tend tskp)
    (interactive "n Start_Time: n End_Time: n Skip_Time: ")
    (number-sequence tstr tend tskp))

You are asking for time and function is asking for number. To me time
is more like 10:01 something rather than 10.

The function definitely returns the list and is handy.

(number-sequence 10 20 2) => (10 12 14 16 18 20)

You need some formatting here:

(interactive "nStart Time: \nnEnd Time: \nnSkip_Time: ")

You can test `interactive' before doing it.

(defun typh-agenda-tgrd (tstr tend tskp)
  (interactive "nStart Time: \nnEnd Time: \nnSkip_Time: ")
  (number-sequence tstr tend tskp))




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

* Re: Elisp - Function returning a list
  2020-12-16  3:25 Elisp - Function returning a list steve-humphreys
  2020-12-16  4:09 ` Jean Louis
@ 2020-12-16  4:13 ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-16  4:13 UTC (permalink / raw)
  To: help-gnu-emacs

steve-humphreys wrote:

> I am having a go at making a function that returns a list of
> numbers, but need it interactive. Unsure this is good

The function that returns the list of number has already been
written, well, as you have discovered.

You need to do something else with it on top of that, otherwise
there isn't any point having it interactive.

> (defun typh-agenda-tgrd (tstr tend tskp)
>    (interactive "n Start_Time: n End_Time: n Skip_Time: ")
>    (number-sequence tstr tend tskp))

Hm, interesting indentation, did you really write that in
emacs-lisp-mode?

Yes, the interactive line is incorrect. You can do something
like this:

(defun num-seq (beg end skip)
  (interactive "nstart: \nnend: \nnskip: ")
  (message "%s" (number-sequence beg end skip) ))

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: Elisp - Function returning a list
  2020-12-16  4:09 ` Jean Louis
@ 2020-12-16  4:17   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16  5:04     ` steve-humphreys
  2020-12-16  4:30   ` Elisp - Function returning a list steve-humphreys
  1 sibling, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-16  4:17 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> You can test `interactive' before doing it.

Yes, good idea. I.e., evaluate the interactive form. Use
`C-x e' after the right paren.

> (defun typh-agenda-tgrd (tstr tend tskp)
>   (interactive "nStart Time: \nnEnd Time: \nnSkip_Time: ")
>   (number-sequence tstr tend tskp))

Yes, but works, but doesn't make any sense. Try invoke it and
see what happens :)

--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: Elisp - Function returning a list
  2020-12-16  4:09 ` Jean Louis
  2020-12-16  4:17   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16  4:30   ` steve-humphreys
  2020-12-16  4:38     ` Yuri Khan
  1 sibling, 1 reply; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  4:30 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help Gnu Emacs

For me 800 is 8 O'Clock

> Sent: Wednesday, December 16, 2020 at 5:09 AM
> From: "Jean Louis" <bugs@gnu.support>
> To: steve-humphreys@gmx.com
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Elisp - Function returning a list
>
> * steve-humphreys@gmx.com <steve-humphreys@gmx.com> [2020-12-16 06:27]:
> >
> > I am having a go at making a function that returns a list of numbers, but need it interactive.
> > Unsure this is good
> >
>  (defun typh-agenda-tgrd (tstr tend tskp)
>     (interactive "n Start_Time: n End_Time: n Skip_Time: ")
>     (number-sequence tstr tend tskp))
>
> You are asking for time and function is asking for number. To me time
> is more like 10:01 something rather than 10.
>
> The function definitely returns the list and is handy.
>
> (number-sequence 10 20 2) => (10 12 14 16 18 20)
>
> You need some formatting here:
>
> (interactive "nStart Time: \nnEnd Time: \nnSkip_Time: ")
>
> You can test `interactive' before doing it.
>
> (defun typh-agenda-tgrd (tstr tend tskp)
>   (interactive "nStart Time: \nnEnd Time: \nnSkip_Time: ")
>   (number-sequence tstr tend tskp))
>
>
>



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

* Re: Elisp - Function returning a list
  2020-12-16  4:30   ` Elisp - Function returning a list steve-humphreys
@ 2020-12-16  4:38     ` Yuri Khan
  2020-12-16  4:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
                         ` (2 more replies)
  0 siblings, 3 replies; 60+ messages in thread
From: Yuri Khan @ 2020-12-16  4:38 UTC (permalink / raw)
  To: steve-humphreys; +Cc: Help Gnu Emacs, Jean Louis

On Wed, 16 Dec 2020 at 11:30, <steve-humphreys@gmx.com> wrote:
>
> For me 800 is 8 O'Clock

You cannot just do decimal arithmetics on times written in that format.

Start: 800  End: 1100  Skip: 45
Expected: 800 845 930 1015 1100
Actual: 800 845 890 935 980 1025 1070



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

* Re: Elisp - Function returning a list
  2020-12-16  4:38     ` Yuri Khan
@ 2020-12-16  4:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16  5:20         ` steve-humphreys
  2020-12-16  5:18       ` steve-humphreys
  2020-12-16  5:33       ` Jean Louis
  2 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-16  4:48 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> For me 800 is 8 O'Clock
>
> You cannot just do decimal arithmetics on times written in
> that format.
>
> Start: 800  End: 1100  Skip: 45
> Expected: 800 845 930 1015 1100
> Actual: 800 845 890 935 980 1025 1070

Arithmetics on time? Is that the purpose?

If so, check out this:

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

(defun wall-clock-time (h1 m1 s1 h2 m2 s2)
  (let*((d   08) ; arbitrary day to use below, any would do
        (m   05) ; actually something cool happened that day
        (y 1978) ; in the history of climbing
        (total-seconds-1 (float-time (encode-time s1 m1 h1 d m y)))
        (total-seconds-2 (float-time (encode-time s2 m2 h2 d m y)))
        (s-diff (- total-seconds-2 total-seconds-1)) )
    (format-seconds "%.2h:%.2m:%.2s" s-diff) ))
(defalias 'wct #'wall-clock-time)
;; (wct 09 35 10 23 00 00) ; 13:24:50
;; (wct 09 35 10 09 35 20) ; 00:00:10

(defun time-between-times (year1 month1 day1
                           year2 month2 day2)
  (let*((seconds-then  (float-time (encode-time 0 0 0 day1 month1 year1)))
        (seconds-now   (float-time (encode-time 0 0 0 day2 month2 year2)))
        (seconds-diff  (- seconds-now seconds-then)) )
    (format-seconds "%yy %dd" seconds-diff)))
;;   (time-between-times 1958  4 13 1958 8 30) ; Tahiti Nui 2 -> 3,
;;                                             ; i.e. 0y 139d

(defun get-time-since (year month day)
  (interactive "nyear: \nnmonth: \nnday: ")
  (message "%s"
           (format-seconds
            "%yy %dd"
            (float-time
             (time-since (encode-time 0 0 0 day month year)) ))))
;; (get-time-since 2011 09 27) ; 8y 228d @ 2020-05-10

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: Elisp - Function returning a list
  2020-12-16  4:17   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16  5:04     ` steve-humphreys
  2020-12-16  5:39       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  5:04 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs


Here's how it makes sense!

Is using "setq frq" and "setq tim" good

--------- code --------

(defun agenda-tgrd (&optional tstr tend tskp)
   "Sets the time grid for the agenda."
   (interactive "n StartTime: \nn EndTime: \nn SkipTime: ")
   (let ( (tstr (or tstr 800))
          (tend (or tend 1500))
          (tskp (or tskp 100))
          frq tim)
      (setq frq '(daily today))
      (setq tim (number-sequence tstr tend tskp))
      (setq org-agenda-time-grid `(,frq ,tim "------" "---"))) )





> Sent: Wednesday, December 16, 2020 at 5:17 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Elisp - Function returning a list
>
> Jean Louis wrote:
>
> > You can test `interactive' before doing it.
>
> Yes, good idea. I.e., evaluate the interactive form. Use
> `C-x e' after the right paren.
>
> > (defun typh-agenda-tgrd (tstr tend tskp)
> >   (interactive "nStart Time: \nnEnd Time: \nnSkip_Time: ")
> >   (number-sequence tstr tend tskp))
>
> Yes, but works, but doesn't make any sense. Try invoke it and
> see what happens :)
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



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

* Re: Elisp - Function returning a list
  2020-12-16  4:38     ` Yuri Khan
  2020-12-16  4:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16  5:18       ` steve-humphreys
  2020-12-16  5:33       ` Jean Louis
  2 siblings, 0 replies; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  5:18 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis



> Sent: Wednesday, December 16, 2020 at 5:38 AM
> From: "Yuri Khan" <yuri.v.khan@gmail.com>
> To: steve-humphreys@gmx.com
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "Jean Louis" <bugs@gnu.support>
> Subject: Re: Elisp - Function returning a list
>
> On Wed, 16 Dec 2020 at 11:30, <steve-humphreys@gmx.com> wrote:
> >
> > For me 800 is 8 O'Clock
>
> You cannot just do decimal arithmetics on times written in that format.
>
> Start: 800  End: 1100  Skip: 45
> Expected: 800 845 930 1015 1100
> Actual: 800 845 890 935 980 1025 1070

Bugger!



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

* Re: Elisp - Function returning a list
  2020-12-16  4:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16  5:20         ` steve-humphreys
  0 siblings, 0 replies; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  5:20 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

> Sent: Wednesday, December 16, 2020 at 5:48 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Elisp - Function returning a list
>
> Yuri Khan wrote:
>
> >> For me 800 is 8 O'Clock
> >
> > You cannot just do decimal arithmetics on times written in
> > that format.
> >
> > Start: 800  End: 1100  Skip: 45
> > Expected: 800 845 930 1015 1100
> > Actual: 800 845 890 935 980 1025 1070
>
> Arithmetics on time? Is that the purpose?

Yes, to set the agenda time grid.

> If so, check out this:
>
> ;;; -*- lexical-binding: t -*-
> ;;;
> ;;; this file:
> ;;;   http://user.it.uu.se/~embe8573/emacs-init/time-cmp.el
> ;;;   https://dataswamp.org/~incal/emacs-init/time-cmp.el
>
> (defun wall-clock-time (h1 m1 s1 h2 m2 s2)
>   (let*((d   08) ; arbitrary day to use below, any would do
>         (m   05) ; actually something cool happened that day
>         (y 1978) ; in the history of climbing
>         (total-seconds-1 (float-time (encode-time s1 m1 h1 d m y)))
>         (total-seconds-2 (float-time (encode-time s2 m2 h2 d m y)))
>         (s-diff (- total-seconds-2 total-seconds-1)) )
>     (format-seconds "%.2h:%.2m:%.2s" s-diff) ))
> (defalias 'wct #'wall-clock-time)
> ;; (wct 09 35 10 23 00 00) ; 13:24:50
> ;; (wct 09 35 10 09 35 20) ; 00:00:10
>
> (defun time-between-times (year1 month1 day1
>                            year2 month2 day2)
>   (let*((seconds-then  (float-time (encode-time 0 0 0 day1 month1 year1)))
>         (seconds-now   (float-time (encode-time 0 0 0 day2 month2 year2)))
>         (seconds-diff  (- seconds-now seconds-then)) )
>     (format-seconds "%yy %dd" seconds-diff)))
> ;;   (time-between-times 1958  4 13 1958 8 30) ; Tahiti Nui 2 -> 3,
> ;;                                             ; i.e. 0y 139d
>
> (defun get-time-since (year month day)
>   (interactive "nyear: \nnmonth: \nnday: ")
>   (message "%s"
>            (format-seconds
>             "%yy %dd"
>             (float-time
>              (time-since (encode-time 0 0 0 day month year)) ))))
> ;; (get-time-since 2011 09 27) ; 8y 228d @ 2020-05-10
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



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

* Re: Elisp - Function returning a list
  2020-12-16  4:38     ` Yuri Khan
  2020-12-16  4:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16  5:18       ` steve-humphreys
@ 2020-12-16  5:33       ` Jean Louis
  2020-12-16  5:42         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 60+ messages in thread
From: Jean Louis @ 2020-12-16  5:33 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Help Gnu Emacs, steve-humphreys

* Yuri Khan <yuri.v.khan@gmail.com> [2020-12-16 07:39]:
> On Wed, 16 Dec 2020 at 11:30, <steve-humphreys@gmx.com> wrote:
> >
> > For me 800 is 8 O'Clock
> 
> You cannot just do decimal arithmetics on times written in that format.
> 
> Start: 800  End: 1100  Skip: 45
> Expected: 800 845 930 1015 1100
> Actual: 800 845 890 935 980 1025 1070

I am using external tools that have features built-in, PostgreSQL
database has it.

(defun my-time-range (time-start add-hours interval-in-minutes)
  (interactive "MBegin time by format HH:MM: \nMFor how many hours later? \nMInterval in minutes: ")
  (let* ((sql (format "SELECT to_char(t.hour::timestamp,'HH:MI') FROM generate_series('2020-01-01 %s:00'::timestamp, '2020-01-01 %s:00'::timestamp + interval '%s hours',  '%s minutes'::interval) as t(hour);" time-start time-start add-hours interval-in-minutes))
	 (command (format "psql -tc \"%s\"" sql)))
    (insert (shell-command-to-string command))))

With: 10:00 and 20 hours later with interval of 35 minutes, result is:

 10:00
 10:35
 11:10
 11:45
 12:20
 12:55
 01:30
 02:05
 02:40
 03:15
 03:50
 04:25
 05:00
 05:35
 06:10
 06:45
 07:20
 07:55
 08:30
 09:05
 09:40
 10:15
 10:50
 11:25
 12:00
 12:35
 01:10
 01:45
 02:20
 02:55
 03:30
 04:05
 04:40
 05:15
 05:50

To make a list from external command, then:

(defun my-time-range (time-start add-hours interval-in-minutes)
  (interactive "MBegin time by format HH:MM: \nMFor how many hours later? \nMInterval in minutes: ")
  (let* ((sql (format "SELECT to_char(t.hour::timestamp,'HH:MI') FROM generate_series('2020-01-01 %s:00'::timestamp, '2020-01-01 %s:00'::timestamp + interval '%s hours',  '%s minutes'::interval) as t(hour);" time-start time-start add-hours interval-in-minutes))
	 (command (format "psql -qtc \"%s\"" sql))
	 (result (shell-command-to-string command))
	 (list (split-string result "\n"))
	 (list (mapcar #'string-trim list))
	 (list (delete-if #'seq-empty-p list)))
    list))

(my-time-range "10:00" "20" "35") => ("10:00" "10:35" "11:10" "11:45" "12:20" "12:55" "01:30" "02:05" "02:40" "03:15" "03:50" "04:25" "05:00" "05:35" "06:10" "06:45" "07:20" "07:55" "08:30" "09:05" "09:40" "10:15" "10:50" "11:25" "12:00" "12:35" "01:10" "01:45" "02:20" "02:55" "03:30" "04:05" "04:40" "05:15" "05:50")

Maybe such Emacs package does exist but if little fiddling with
the external tool helps me to get the range, then I use external
tool.

Jean



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

* Re: Elisp - Function returning a list
  2020-12-16  5:04     ` steve-humphreys
@ 2020-12-16  5:39       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16  7:36         ` steve-humphreys
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-16  5:39 UTC (permalink / raw)
  To: help-gnu-emacs

steve-humphreys wrote:

> Is using "setq frq" and "setq tim" good
>
> (defun agenda-tgrd (&optional tstr tend tskp)
>    "Sets the time grid for the agenda."
>    (interactive "n StartTime: \nn EndTime: \nn SkipTime: ")
>    (let ( (tstr (or tstr 800))
>           (tend (or tend 1500))
>           (tskp (or tskp 100))
>           frq tim)
>       (setq frq '(daily today))
>       (setq tim (number-sequence tstr tend tskp))
>       (setq org-agenda-time-grid `(,frq ,tim "------" "---"))) )

It is better to do all computation in the `let's, then use
them. No `setq' needed.

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: Elisp - Function returning a list
  2020-12-16  5:33       ` Jean Louis
@ 2020-12-16  5:42         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16  8:01           ` Elisp - Function returning a sequence of times Jean Louis
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-16  5:42 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> I am using external tools

Me too, here is some zsh:

  https://dataswamp.org/~incal/conf/.zsh/time

and a screenshot:

  https://dataswamp.org/~incal/pimgs/comp/clocks.png

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: Elisp - Function returning a list
  2020-12-16  5:39       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16  7:36         ` steve-humphreys
  2020-12-16  8:55           ` Joost Kremers
                             ` (2 more replies)
  0 siblings, 3 replies; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  7:36 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

> Sent: Wednesday, December 16, 2020 at 6:39 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Elisp - Function returning a list
>
> steve-humphreys wrote:
>
> > Is using "setq frq" and "setq tim" good
> >
> > (defun agenda-tgrd (&optional tstr tend tskp)
> >    "Sets the time grid for the agenda."
> >    (interactive "n StartTime: \nn EndTime: \nn SkipTime: ")
> >    (let ( (tstr (or tstr 800))
> >           (tend (or tend 1500))
> >           (tskp (or tskp 100))
> >           frq tim)
> >       (setq frq '(daily today))
> >       (setq tim (number-sequence tstr tend tskp))
> >       (setq org-agenda-time-grid `(,frq ,tim "------" "---"))) )
>
> It is better to do all computation in the `let's, then use
> them. No `setq' needed.

Example? Is there anything written about it?

> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



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

* Re: Elisp - Function returning a sequence of times
  2020-12-16  5:42         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16  8:01           ` Jean Louis
  2020-12-16  9:05             ` steve-humphreys
  2020-12-16 21:54             ` Michael Heerdegen
  0 siblings, 2 replies; 60+ messages in thread
From: Jean Louis @ 2020-12-16  8:01 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-16 08:53]:
> Jean Louis wrote:
> 
> > I am using external tools
> 
> Me too, here is some zsh:
> 
>   https://dataswamp.org/~incal/conf/.zsh/time
> 
> and a screenshot:
> 
>   https://dataswamp.org/~incal/pimgs/comp/clocks.png

Looks like prompt, is it? Huge calendar prompt. OK fine. Could be also
used to show upcoming appointments.

Emacs must have those date/time features and adding times
somewhere. But where?

(info "(elisp) Time Calculations")

time-add is a built-in function in ‘src/timefns.c’.

(time-add A B) 

In the manual there is more references:

          (let ((time (decode-time nil nil t))
                (delta (make-decoded-time :month 2)))
            (encode-time (decoded-time-add time delta)))

(make-decoded-time :hour 10 :minute 20) => (nil 20 10 nil nil nil nil nil nil)

This adds 360 seconds to current-time:
(time-add (current-time) 360)

(defun my-days (days)
  "Returns seconds for days"
  (* 24 3600 days))

(defun my-minutes (minutes)
  "Returns seconds for minutes"
  (* 60 minutes))

(my-minutes 35)
2100

(format-time-string "%H:%M" (current-time))
"10:57"

(time-add (current-time) (my-minutes 35))
(24537 50767 754967 229000)

(format-time-string "%H:%M" (time-add (current-time) (my-minutes 35)))
"11:33"

So adding works in plain Emacs.

What I do not know is how to convert 10:57 time to TIME format
like: (24537 50767 754967 229000)

And because function requires only time as hours and minutes, the
date would not matter.

Once that is found, how to convert any TIME:MINUTES to that TIME
format: (24537 50767 754967 229000) then it will be easy to make
function that adds minutes or specified hours or minutes to it
and produces a sequence.

Jean





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

* Re: Elisp - Function returning a list
  2020-12-16  7:36         ` steve-humphreys
@ 2020-12-16  8:55           ` Joost Kremers
  2020-12-16 10:25           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16 11:52           ` let, let*, oh, why [was: Elisp - Function returning a list] tomas
  2 siblings, 0 replies; 60+ messages in thread
From: Joost Kremers @ 2020-12-16  8:55 UTC (permalink / raw)
  To: steve-humphreys; +Cc: help-gnu-emacs, moasenwood


On Wed, Dec 16 2020, steve-humphreys@gmx.com wrote:
>> Sent: Wednesday, December 16, 2020 at 6:39 AM
>> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
>> To: help-gnu-emacs@gnu.org
>> Subject: Re: Elisp - Function returning a list
>>
>> steve-humphreys wrote:
>>
>> > Is using "setq frq" and "setq tim" good
>> >
>> > (defun agenda-tgrd (&optional tstr tend tskp)
>> >    "Sets the time grid for the agenda."
>> >    (interactive "n StartTime: \nn EndTime: \nn SkipTime: ")
>> >    (let ( (tstr (or tstr 800))
>> >           (tend (or tend 1500))
>> >           (tskp (or tskp 100))
>> >           frq tim)
>> >       (setq frq '(daily today))
>> >       (setq tim (number-sequence tstr tend tskp))
>> >       (setq org-agenda-time-grid `(,frq ,tim "------" "---"))) )
>>
>> It is better to do all computation in the `let's, then use
>> them. No `setq' needed.
>
> Example? Is there anything written about it?

You can use `let*` instead of `let`:

```
(defun agenda-tgrd (&optional tstr tend tskp)
  "Set the time grid for the agenda."
  (interactive "n StartTime: \nn EndTime: \nn SkipTime: ")
  (let* ((tstr (or tstr 800))
         (tend (or tend 1500))
         (tskp (or tskp 100))
         (frq '(daily today))
         (tim (number-sequence tstr tend tskp)))
    (setq org-agenda-time-grid (list frq tim "------" "---"))))
```

(You really only need `let*` for `tim`, in this case; even in your version there
was no need to give `frq` a value with `setq`).

Some small nitpicks: I'd use `list` instead of backquote-unquote to create
a list. And the doc string conventions in Elisp say to use the imperative
instead of third person singular, so "Set the time grid" rather than "Sets the
time grid". But those are stylistic and therefore personal choices, of course. :-)

-- 
Joost Kremers
Life has its moments



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

* Re: Elisp - Function returning a sequence of times
  2020-12-16  8:01           ` Elisp - Function returning a sequence of times Jean Louis
@ 2020-12-16  9:05             ` steve-humphreys
  2020-12-16  9:20               ` Joost Kremers
  2020-12-16 21:54             ` Michael Heerdegen
  1 sibling, 1 reply; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  9:05 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs

I have done something like this, but need help to finalise the actual function.
Do you agree on this solution?


(defun timfutur ()
   (interactive)
   (setq tm 845)
   (setq tsk 30)
   (setq thr (/ tm 100))
   (setq tmn (- tm (* thr 100)))
   (setq tmn-futur (% (+ tmn tsk) 60))
   (setq thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24))
   (message "%d %d %d%d" thr tmn thr-futur tmn-futur))



> Sent: Wednesday, December 16, 2020 at 9:01 AM
> From: "Jean Louis" <bugs@gnu.support>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Elisp - Function returning a sequence of times
>
> * Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-16 08:53]:
> > Jean Louis wrote:
> > 
> > > I am using external tools
> > 
> > Me too, here is some zsh:
> > 
> >   https://dataswamp.org/~incal/conf/.zsh/time
> > 
> > and a screenshot:
> > 
> >   https://dataswamp.org/~incal/pimgs/comp/clocks.png
> 
> Looks like prompt, is it? Huge calendar prompt. OK fine. Could be also
> used to show upcoming appointments.
> 
> Emacs must have those date/time features and adding times
> somewhere. But where?
> 
> (info "(elisp) Time Calculations")
> 
> time-add is a built-in function in ‘src/timefns.c’.
> 
> (time-add A B) 
> 
> In the manual there is more references:
> 
>           (let ((time (decode-time nil nil t))
>                 (delta (make-decoded-time :month 2)))
>             (encode-time (decoded-time-add time delta)))
> 
> (make-decoded-time :hour 10 :minute 20) => (nil 20 10 nil nil nil nil nil nil)
> 
> This adds 360 seconds to current-time:
> (time-add (current-time) 360)
> 
> (defun my-days (days)
>   "Returns seconds for days"
>   (* 24 3600 days))
> 
> (defun my-minutes (minutes)
>   "Returns seconds for minutes"
>   (* 60 minutes))
> 
> (my-minutes 35)
> 2100
> 
> (format-time-string "%H:%M" (current-time))
> "10:57"
> 
> (time-add (current-time) (my-minutes 35))
> (24537 50767 754967 229000)
> 
> (format-time-string "%H:%M" (time-add (current-time) (my-minutes 35)))
> "11:33"
> 
> So adding works in plain Emacs.
> 
> What I do not know is how to convert 10:57 time to TIME format
> like: (24537 50767 754967 229000)
> 
> And because function requires only time as hours and minutes, the
> date would not matter.
> 
> Once that is found, how to convert any TIME:MINUTES to that TIME
> format: (24537 50767 754967 229000) then it will be easy to make
> function that adds minutes or specified hours or minutes to it
> and produces a sequence.
> 
> Jean
> 
> 
> 
>



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

* Re: Elisp - Function returning a sequence of times
  2020-12-16  9:05             ` steve-humphreys
@ 2020-12-16  9:20               ` Joost Kremers
  2020-12-16  9:40                 ` steve-humphreys
  0 siblings, 1 reply; 60+ messages in thread
From: Joost Kremers @ 2020-12-16  9:20 UTC (permalink / raw)
  To: steve-humphreys; +Cc: help-gnu-emacs


On Wed, Dec 16 2020, steve-humphreys@gmx.com wrote:
> I have done something like this, but need help to finalise the actual function.
> Do you agree on this solution?
>
>
> (defun timfutur ()
>    (interactive)
>    (setq tm 845)
>    (setq tsk 30)
>    (setq thr (/ tm 100))
>    (setq tmn (- tm (* thr 100)))
>    (setq tmn-futur (% (+ tmn tsk) 60))
>    (setq thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24))
>    (message "%d %d %d%d" thr tmn thr-futur tmn-futur))

My humble opinion: try to avoid `setq` at all cost. It has some legitimate uses,
but they're far and few between.

```
(defun timfutur ()
  (interactive)
  (let* ((tm 845)
         (tsk 30)
         (thr (/ tm 100))
         (tmn (- tm (* thr 100)))
         (tmn-futur (% (+ tmn tsk) 60))
         (thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24)))
    (message "%d %d %d%d" thr tmn thr-futur tmn-futur)))
```

-- 
Joost Kremers
Life has its moments



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

* Re: Elisp - Function returning a sequence of times
  2020-12-16  9:20               ` Joost Kremers
@ 2020-12-16  9:40                 ` steve-humphreys
  0 siblings, 0 replies; 60+ messages in thread
From: steve-humphreys @ 2020-12-16  9:40 UTC (permalink / raw)
  To: Joost Kremers; +Cc: help-gnu-emacs

Just made it quick, the focus is on the calculation for the new time.

> Sent: Wednesday, December 16, 2020 at 10:20 AM
> From: "Joost Kremers" <joostkremers@fastmail.fm>
> To: steve-humphreys@gmx.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Elisp - Function returning a sequence of times
>
>
> On Wed, Dec 16 2020, steve-humphreys@gmx.com wrote:
> > I have done something like this, but need help to finalise the actual function.
> > Do you agree on this solution?
> >
> >
> > (defun timfutur ()
> >    (interactive)
> >    (setq tm 845)
> >    (setq tsk 30)
> >    (setq thr (/ tm 100))
> >    (setq tmn (- tm (* thr 100)))
> >    (setq tmn-futur (% (+ tmn tsk) 60))
> >    (setq thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24))
> >    (message "%d %d %d%d" thr tmn thr-futur tmn-futur))
>
> My humble opinion: try to avoid `setq` at all cost. It has some legitimate uses,
> but they're far and few between.
>
> ```
> (defun timfutur ()
>   (interactive)
>   (let* ((tm 845)
>          (tsk 30)
>          (thr (/ tm 100))
>          (tmn (- tm (* thr 100)))
>          (tmn-futur (% (+ tmn tsk) 60))
>          (thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24)))
>     (message "%d %d %d%d" thr tmn thr-futur tmn-futur)))
> ```
>
> --
> Joost Kremers
> Life has its moments
>
>



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

* Re: Elisp - Function returning a list
  2020-12-16  7:36         ` steve-humphreys
  2020-12-16  8:55           ` Joost Kremers
@ 2020-12-16 10:25           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16 11:52           ` let, let*, oh, why [was: Elisp - Function returning a list] tomas
  2 siblings, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-16 10:25 UTC (permalink / raw)
  To: help-gnu-emacs

steve-humphreys wrote:

>>> Is using "setq frq" and "setq tim" good
>>>
>>> (defun agenda-tgrd (&optional tstr tend tskp)
>>>    "Sets the time grid for the agenda."
>>>    (interactive "n StartTime: \nn EndTime: \nn SkipTime: ")
>>>    (let ( (tstr (or tstr 800))
>>>           (tend (or tend 1500))
>>>           (tskp (or tskp 100))
>>>           frq tim)
>>>       (setq frq '(daily today))
>>>       (setq tim (number-sequence tstr tend tskp))
>>>       (setq org-agenda-time-grid `(,frq ,tim "------" "---"))) )
>>
>> It is better to do all computation in the `let's, then use
>> them. No `setq' needed.
>
> Example? Is there anything written about it?

Here, use `let*' instead of `let'. You already know how to do
let and to do the computation. So you don't need an example...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16  7:36         ` steve-humphreys
  2020-12-16  8:55           ` Joost Kremers
  2020-12-16 10:25           ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16 11:52           ` tomas
  2020-12-16 14:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 60+ messages in thread
From: tomas @ 2020-12-16 11:52 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Wed, Dec 16, 2020 at 08:36:03AM +0100, steve-humphreys@gmx.com wrote:
> > From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>

[...]

> > It is better to do all computation in the `let's, then use
> > them. No `setq' needed.

I generally agree, but not 100% (all generalizations suck, you know ;-)

> Example? Is there anything written about it?

What setq does is to "search upwards" from where it is until it
"finds the variable", and then sets its value as instructed.

If it doesn't find that variable, it creates a new one at the
"top level", to be able to accomplish this task.

I put "search upwards" and "find the variable" in quotes, because
they deserve some explanation. I'll limit myself here to the
"upwards" part:

What "upwards" means depends on whether you are under dynamic
scope (traditional) or lexical scope (more modern, recommended
almost always).

Under dynamic scope, the search for the variable goes up the call
chain: if the function where the setq is in "sees" that variable,
then it's there. Otherwise it asks its caller, and so on.

Under lexical scope, the search considers the source code: if
that variable is visible/defined in the current expression (think
"block", if you're coming from C/Perl/Python/PHP/Java), then that's
it. Otherwise go look in the enclosing expression.

Needless to say, this is the source of lots of fun: if you are
doing something in your code and import a snippet of code from
elsewhere (for the lexical case) or just call some code elsewhere,
and "they" trample on your "variables", spooky things happen.

In the dynamic case, those things are very spooky. Imagine
you have some code:

  (setq x 3)
  (setq y 4)

and call on Tomas's library to get the last mouse click coordinates.

  (setq mouse-x (car (tomas-coords)))

Jane's library does this (CAVEAT: there are nicer ways to do this,
apart from the "obvious" error that this function tramples over
whatever values mouse-pos, x, and y might have "globally".

I'm doing that to have a small working example. I repeat: DON'T DO
IT THIS WAY ;-)

  (defun tomas-coords ()
    (setq mouse-pos (mouse-position)) ; elisp manual 29.16
    ;; mouse-position has as first arg the frame. Let's get rid of that:
    (setq x (cadr mouse-pos))
    (setq y (cddr mouse-pos))
    (cons x y)) ;; return the pair (x . y)

Now your 'x' above isn't 3 anymore, but has some random value depending
on where your user was wiggling around the mouse. Oops.

Now under lexical scope things aren't so bleak, but still annoying.

That's why function arguments and let are there. They create a
kind of barrier for private variable names. A slightly better
version of the above function would then be:

  (defun tomas-coords ()
    (let ((mouse-pos (mouse-position))) ; elisp manual 29.16
      ;; mouse-position has as first arg the frame. Let's get rid of that:
      (let ((x (cadr mouse-pos))
            (y (cddr mouse-pos)))
        (cons x y)))) ;; return the pair (x . y)
      
So the `let' is telling elisp: "look, we are introducing here a
new variable called `x'. It has nothing to do with any other `x'
out/up there". Or "Any Similarity to Persons Living or Dead is
Purely Coincidental", as some like to put it. Still, the "here"
in the phrase above is interpreted differently depending on
whether we're "flying" dynamically or lexically.

Why the two nested `let's above, you ask? Well, in the variable-
assignment part of a let each arm is independent of the others.

The line above ...(y (cddr mouse-pos)) doesn't "see" the `x'
defined above it. It is as if all those parts were happening
at the same time. So for the `x' and `y' assignments to "see"
the just assigned `mouse-pos', we must `let' that happen
before.

That's why `let*' has been invented. Basically,

  (let* ((foo blah)
         (bar bleh)
         (baz mih))
    ...)

is equivalent, but arguably more readable than

  (let ((foo blah))
     (let ((bar bleh))
       (let ((baz mih))
         ...)))

HTH
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 11:52           ` let, let*, oh, why [was: Elisp - Function returning a list] tomas
@ 2020-12-16 14:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-16 15:10               ` Jean Louis
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-16 14:13 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> What "upwards" means depends on whether you are under
> dynamic scope (traditional) or lexical scope (more modern,
> recommended almost always).

Indeed, put this topmost in your Elisp files:

;;; -*- lexical-binding: t -*-

Then use `let' and `let*'.

Write code as one intuitively does, based on functions that do
stuff and/or return stuff.

When done, byte compile.

Simple simple simple. Actually it is much easier to do right
than to do wrong in this case.

But ... to be fair it also works like this:

(defvar some-var)
(setq some-var 0) ; 0

(defun test-var ()
  (let ((some-var 1))
    (setq some-var 2)
    some-var) )

(test-var) ; 2

some-var ; 0

But it is still ugly and error prone. If you make a typo it
won't tell you when you evaluate the function:

(defvar some-var)
(setq some-var 0) ; 0

(defun test-var ()
  (let ((some-var 1))
    (setq some-vari 2) ; oups
    some-var) )

(test-var) ; 1 ???

some-var ; 0

But the byte-compiler will:

  In test-var:
  geh.el:210:11: Warning: assignment to free variable ‘some-vari’

So, better to do all computation in the `let's, then use them
in the body. Yes, nest lets where needed... let is supposedly
parallel while let* is sequential but in practice it most
often means with let* you can see the vars and their values
later or in the varlist...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 14:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-16 15:10               ` Jean Louis
  2020-12-16 15:58                 ` Stefan Monnier
  2020-12-18 14:27                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 60+ messages in thread
From: Jean Louis @ 2020-12-16 15:10 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-16 17:34]:
> tomas wrote:
> 
> > What "upwards" means depends on whether you are under
> > dynamic scope (traditional) or lexical scope (more modern,
> > recommended almost always).
> 
> Indeed, put this topmost in your Elisp files:
> 
> ;;; -*- lexical-binding: t -*-

That line is somehow out of sight for me so I just use:

(setq lexical-binding t) as first line in the file.

> Then use `let' and `let*'.
> 
> Write code as one intuitively does, based on functions that do
> stuff and/or return stuff.
> 
> When done, byte compile.
> 
> Simple simple simple. Actually it is much easier to do right
> than to do wrong in this case.

I do follow that workflow as you explained, but it took me time to
find out about it. I do not find it all simple as workflows like that
are not described anywhere. Functions are described in the manual and
everything is there but general practical workflows are not there. In
other words instructions are not well integrated.

Environments like Dr. Racket also try to be self-documented. I still
find Emacs better self-documented than other similar environments.

There are no big deals with dynamic variables as well, one can program
for years without real problem. Then if programmer knows the problem
one can continue programming for decades without entering into
problem. 

> But the byte-compiler will:
> 
>   In test-var:
>   geh.el:210:11: Warning: assignment to free variable ‘some-vari’

Good to have such messages.




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 15:10               ` Jean Louis
@ 2020-12-16 15:58                 ` Stefan Monnier
  2020-12-16 18:37                   ` Jean Louis
  2020-12-18 14:27                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 60+ messages in thread
From: Stefan Monnier @ 2020-12-16 15:58 UTC (permalink / raw)
  To: help-gnu-emacs

> That line is somehow out of sight for me so I just use:
> (setq lexical-binding t) as first line in the file.

That doesn't do what you usually want.


        Stefan




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 15:58                 ` Stefan Monnier
@ 2020-12-16 18:37                   ` Jean Louis
  2020-12-16 19:04                     ` Stefan Monnier
  0 siblings, 1 reply; 60+ messages in thread
From: Jean Louis @ 2020-12-16 18:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

* Stefan Monnier <monnier@iro.umontreal.ca> [2020-12-16 18:59]:
> > That line is somehow out of sight for me so I just use:
> > (setq lexical-binding t) as first line in the file.
> 
> That doesn't do what you usually want.

Help me to understand why?

Jean



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 18:37                   ` Jean Louis
@ 2020-12-16 19:04                     ` Stefan Monnier
  2020-12-16 20:05                       ` Jean Louis
                                         ` (2 more replies)
  0 siblings, 3 replies; 60+ messages in thread
From: Stefan Monnier @ 2020-12-16 19:04 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs

>> That doesn't do what you usually want.
> Help me to understand why?

https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00750.html


        Stefan




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 19:04                     ` Stefan Monnier
@ 2020-12-16 20:05                       ` Jean Louis
  2020-12-16 20:34                         ` tomas
  2020-12-16 20:06                       ` tomas
  2020-12-18 15:08                       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 60+ messages in thread
From: Jean Louis @ 2020-12-16 20:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

* Stefan Monnier <monnier@iro.umontreal.ca> [2020-12-16 22:05]:
> >> That doesn't do what you usually want.
> > Help me to understand why?
> 
> https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00750.html

Is it possible to show example that it will not work as expected?




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 19:04                     ` Stefan Monnier
  2020-12-16 20:05                       ` Jean Louis
@ 2020-12-16 20:06                       ` tomas
  2020-12-18 15:08                       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 0 replies; 60+ messages in thread
From: tomas @ 2020-12-16 20:06 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Wed, Dec 16, 2020 at 02:04:59PM -0500, Stefan Monnier wrote:
> >> That doesn't do what you usually want.
> > Help me to understand why?
> 
> https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00750.html

Heh. You've beat me to it :)

Cheers
-- t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 20:05                       ` Jean Louis
@ 2020-12-16 20:34                         ` tomas
  0 siblings, 0 replies; 60+ messages in thread
From: tomas @ 2020-12-16 20:34 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Wed, Dec 16, 2020 at 11:05:36PM +0300, Jean Louis wrote:
> * Stefan Monnier <monnier@iro.umontreal.ca> [2020-12-16 22:05]:
> > >> That doesn't do what you usually want.
> > > Help me to understand why?
> > 
> > https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00750.html
> 
> Is it possible to show example that it will not work as expected?

Compose a file roughly like this:

  (let ((canary 'lexical))
    (defun test-binding ()
      (insert (format "binding is %S" canary))))

  (let ((canary 'dynamic))
    (test-binding))

Now save it, say as /tmp/foo.el.

Next, from some buffer (say *scratch*), do M-x load-file <ENTER> /tmp/foo.el <ENTER>.

This will put in your buffer "binding is dynamic" (since that's the
default).

Now test again

 (1) having inserted (setq lexical-binding t) at the top of the above
     file

 (2)  having inserted -*- lexical-binding: t -*- at the top of the
      above file.

Compare results. Discuss :-)

(Cheatsheet: in case (1), the variable `lexical-binding' has been set
in the buffer from which you called `load-file', which was, if you
chose the same setting as me, *scratch*. In the second case, the
setting of the lexical binding was effective for the source file
itself, i.e. foo.el)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: Elisp - Function returning a sequence of times
  2020-12-16  8:01           ` Elisp - Function returning a sequence of times Jean Louis
  2020-12-16  9:05             ` steve-humphreys
@ 2020-12-16 21:54             ` Michael Heerdegen
  1 sibling, 0 replies; 60+ messages in thread
From: Michael Heerdegen @ 2020-12-16 21:54 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> (time-add A B) 

> (make-decoded-time :hour 10 :minute 20) => (nil 20 10 nil nil nil nil nil nil)
>
> This adds 360 seconds to current-time:
> (time-add (current-time) 360)

BTW, this also works:

| (format-time-string "%Mm %Ss" (seconds-to-time 150)) ==> "02m 30s"

i.e. it's possible to convert a number of seconds to a timestamp
(string).

Michael.




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 15:10               ` Jean Louis
  2020-12-16 15:58                 ` Stefan Monnier
@ 2020-12-18 14:27                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-18 17:42                   ` Jean Louis
  1 sibling, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-18 14:27 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> Then use `let' and `let*'.
>> 
>> Write code as one intuitively does, based on functions that
>> do stuff and/or return stuff.
>> 
>> When done, byte compile.
>> 
>> Simple simple simple. Actually it is much easier to do
>> right than to do wrong in this case.
>
> I do follow that workflow as you explained, but it took me time to
> find out about it. I do not find it all simple as workflows like that
> are not described anywhere.

Well, it is intuitive to use let instead of creating global
variables outside of the function. Isn't it? Well, to me it
is. lexical-scope is intuitive in that it makes the most sense
and is what you are used to from other languages, yeah, Lisp
wasn't my first language. I think Basic, then C?

> There are no big deals with dynamic variables as well, one
> can program for years without real problem.

That's right, I did so for many years without knowing about
this distinction at all, what I remember the transition to
lexical was done with only a few very minor changes. But then
I again, to me lexical is they way I always did it and it
makes the most sense, you enclose the code in blocks and
levels, and what you do, you don't want anything else to
interfere with it, and you don't want it to interfere with
anything else outside of it...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-16 19:04                     ` Stefan Monnier
  2020-12-16 20:05                       ` Jean Louis
  2020-12-16 20:06                       ` tomas
@ 2020-12-18 15:08                       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-18 15:08 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

>>> That doesn't do what you usually want.
>>
>> Help me to understand why?
>
> https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00750.html

Maybe a line in the docstring of `lexical-binding' would be
in place?

I always did ;;; -*- lexical-binding: t -*- and it does make
sense that (setq lexical-binding t) doesn't "work" but one can
easily imagine a misunderstanding taking place. Or we just saw
it, actually, with a reference at that, so we don't even have
to imagine...

*chuckle*

This only underscores what J. Louis just said!

> There are no big deals with dynamic variables as well, one
> can program for years without real problem.

That's right! Just program soundly and this corresponds to the
lexical style to the point that even in dynamic mode, it won't
cause any problems :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-18 14:27                 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-18 17:42                   ` Jean Louis
  2020-12-18 20:57                     ` Eli Zaretskii
  2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 60+ messages in thread
From: Jean Louis @ 2020-12-18 17:42 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-18 17:28]:
> Well, it is intuitive to use let instead of creating global
> variables outside of the function. Isn't it? Well, to me it
> is. lexical-scope is intuitive in that it makes the most sense
> and is what you are used to from other languages, yeah, Lisp
> wasn't my first language. I think Basic, then C?

I did learn BASIC, then assembler, then machine language directly on
65C02 processor. Then we got LOGO and I learned it and it was
interesting. Years later I came to LISP and I find it is almost same
as LOGO, that is where I found familiarity.

As we were not exposed to free software and only to proprietary
software I did not have opportunity to access or learn other
languages. All the marketing was about proprietary software. Many
years I lost without liberties.





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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-18 17:42                   ` Jean Louis
@ 2020-12-18 20:57                     ` Eli Zaretskii
  2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 60+ messages in thread
From: Eli Zaretskii @ 2020-12-18 20:57 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 18 Dec 2020 20:42:16 +0300
> From: Jean Louis <bugs@gnu.support>
> 
> Then we got LOGO and I learned it and it was interesting. Years
> later I came to LISP and I find it is almost same as LOGO, that is
> where I found familiarity.

It's actually the other way around: Logo was conceived as a kind-of
dialect of Lisp (with "turtle graphics" added to make it easier to
teach kids).  I still have the 3 volumes of "Computer Science Logo
Style" on my shelf.



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-18 17:42                   ` Jean Louis
  2020-12-18 20:57                     ` Eli Zaretskii
@ 2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-20  5:06                       ` Thien-Thi Nguyen
                                         ` (3 more replies)
  1 sibling, 4 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-20  4:49 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> I did learn BASIC, then assembler, then machine language
> directly on 65C02 processor. Then we got LOGO and I learned
> it and it was interesting. Years later I came to LISP and
> I find it is almost same as LOGO, that is where
> I found familiarity.

Never heard of Logo, thanks, got to update my history file:

  https://dataswamp.org/~incal/COMP-HIST

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-20  5:06                       ` Thien-Thi Nguyen
  2020-12-20  7:02                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-20  6:21                       ` Jean Louis
                                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 60+ messages in thread
From: Thien-Thi Nguyen @ 2020-12-20  5:06 UTC (permalink / raw)
  To: help-gnu-emacs

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


() Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
() Sun, 20 Dec 2020 05:49:51 +0100

   Never heard of Logo

Boggle!

I thought all two-wheels-good folks knew about Logo!  :-D

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (query)               ; (2020) Software Libero
   (pcase (context query)               ;       = Dissenso Etico
     (`(technical ,ml) (correctp ml))
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 219 bytes --]

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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-20  5:06                       ` Thien-Thi Nguyen
@ 2020-12-20  6:21                       ` Jean Louis
  2020-12-20 23:20                       ` Drew Adams
  2020-12-25 14:41                       ` 황병희
  3 siblings, 0 replies; 60+ messages in thread
From: Jean Louis @ 2020-12-20  6:21 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-20 07:50]:
> Jean Louis wrote:
> 
> > I did learn BASIC, then assembler, then machine language
> > directly on 65C02 processor. Then we got LOGO and I learned
> > it and it was interesting. Years later I came to LISP and
> > I find it is almost same as LOGO, that is where
> > I found familiarity.
> 
> Never heard of Logo, thanks, got to update my history file:
> 
>   https://dataswamp.org/~incal/COMP-HIST

There was turtle graphics for Emacs but program is lost, I cannot find
it.



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  5:06                       ` Thien-Thi Nguyen
@ 2020-12-20  7:02                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-20  7:16                           ` Thien-Thi Nguyen
  2020-12-20 13:38                           ` Jean Louis
  0 siblings, 2 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-20  7:02 UTC (permalink / raw)
  To: help-gnu-emacs

Thien-Thi Nguyen wrote:

> Boggle!
>
> I thought all two-wheels-good folks knew about Logo! :-D

Okay, well now I have joined them :)

But what is special about it?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  7:02                         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-20  7:16                           ` Thien-Thi Nguyen
  2020-12-21  2:34                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-20 13:38                           ` Jean Louis
  1 sibling, 1 reply; 60+ messages in thread
From: Thien-Thi Nguyen @ 2020-12-20  7:16 UTC (permalink / raw)
  To: help-gnu-emacs

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


() Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
() Sun, 20 Dec 2020 08:02:24 +0100

   But what is special about it?

To two-wheels-good folks, anything that has a tendency to make
spirograph[0] art is beautiful, in both the process (or precess,
yuk yuk) and the result.  Sometimes beauty can be special.  :-D

[0] https://en.wikipedia.org/wiki/Spirograph

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (query)               ; (2020) Software Libero
   (pcase (context query)               ;       = Dissenso Etico
     (`(technical ,ml) (correctp ml))
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 219 bytes --]

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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  7:02                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-20  7:16                           ` Thien-Thi Nguyen
@ 2020-12-20 13:38                           ` Jean Louis
  1 sibling, 0 replies; 60+ messages in thread
From: Jean Louis @ 2020-12-20 13:38 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-20 10:06]:
> Thien-Thi Nguyen wrote:
> 
> > Boggle!
> >
> > I thought all two-wheels-good folks knew about Logo! :-D
> 
> Okay, well now I have joined them :)
> 
> But what is special about it?

It helps beginner programmers to understand what are those computers
commands, functions, variables and they may mathematically create
visual pictures.

There is program kturtle in KDE that helps in learning to program.

Jean



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

* RE: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-20  5:06                       ` Thien-Thi Nguyen
  2020-12-20  6:21                       ` Jean Louis
@ 2020-12-20 23:20                       ` Drew Adams
  2020-12-21  4:50                         ` Jean Louis
  2020-12-25 14:41                       ` 황병희
  3 siblings, 1 reply; 60+ messages in thread
From: Drew Adams @ 2020-12-20 23:20 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

> Never heard of Logo, thanks, got to update my history file:

https://en.wikipedia.org/wiki/Mindstorms_(book)



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  7:16                           ` Thien-Thi Nguyen
@ 2020-12-21  2:34                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-21  2:34 UTC (permalink / raw)
  To: help-gnu-emacs

Thien-Thi Nguyen wrote:

> Sometimes beauty can be special. :-D

Beautify the moment!

Swedish: Försköna stunden

Not: För sköna stunder :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20 23:20                       ` Drew Adams
@ 2020-12-21  4:50                         ` Jean Louis
  2020-12-21  5:40                           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 60+ messages in thread
From: Jean Louis @ 2020-12-21  4:50 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs, Emanuel Berg

Official LOGO resources:
https://el.media.mit.edu/logo-foundation/what_is_logo/logo_and_natural_language.html




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-21  4:50                         ` Jean Louis
@ 2020-12-21  5:40                           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-21  9:17                             ` tomas
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-21  5:40 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> Official LOGO resources:
> https://el.media.mit.edu/logo-foundation/what_is_logo/logo_and_natural_language.html

Looks like an old-school official URL...

What's so special about it?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-21  5:40                           ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-21  9:17                             ` tomas
  2020-12-21 15:20                               ` Drew Adams
  0 siblings, 1 reply; 60+ messages in thread
From: tomas @ 2020-12-21  9:17 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Mon, Dec 21, 2020 at 06:40:03AM +0100, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Jean Louis wrote:
> 
> > Official LOGO resources:
> > https://el.media.mit.edu/logo-foundation/what_is_logo/logo_and_natural_language.html
> 
> Looks like an old-school official URL...
> 
> What's so special about it?

About the URL? Well, perhaps that it doesn't try to take over your
computer with some sleazy javascript. I appreciate that more and
more.

About Logo? Many things. The minimalist way to achieve direct visual 
feedback (via Turtle graphics). The shell-y syntax, which makes REPL
pleasant. But first of all: it's Lisp. In a package with a shiny label
"For Our Kids" on it. It's a Trojan Horse ;-D

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* RE: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-21  9:17                             ` tomas
@ 2020-12-21 15:20                               ` Drew Adams
  2020-12-21 15:50                                 ` tomas
  0 siblings, 1 reply; 60+ messages in thread
From: Drew Adams @ 2020-12-21 15:20 UTC (permalink / raw)
  To: tomas, help-gnu-emacs

Wrt Turtle Geometry, here's a good book:

https://mitpress.mit.edu/books/turtle-geometry

Like Mindstorms, it's fairly old, but very good.



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-21 15:20                               ` Drew Adams
@ 2020-12-21 15:50                                 ` tomas
  0 siblings, 0 replies; 60+ messages in thread
From: tomas @ 2020-12-21 15:50 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

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

On Mon, Dec 21, 2020 at 07:20:02AM -0800, Drew Adams wrote:
> Wrt Turtle Geometry, here's a good book:
> 
> https://mitpress.mit.edu/books/turtle-geometry

By Harold Abelson and Andrea diSessa.

The first author rings a bell ;-)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
                                         ` (2 preceding siblings ...)
  2020-12-20 23:20                       ` Drew Adams
@ 2020-12-25 14:41                       ` 황병희
  2020-12-26  4:22                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  3 siblings, 1 reply; 60+ messages in thread
From: 황병희 @ 2020-12-25 14:41 UTC (permalink / raw)
  To: help-gnu-emacs

>   https://dataswamp.org/~incal/COMP-HIST

Thanks Emanuel^^^ i did add the url in my firefox's bookmark.

Sincerely, Gnus fan Byung-Hee

-- 
^고맙습니다 _救濟蒼生_ 감사합니다_^))//

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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-25 14:41                       ` 황병희
@ 2020-12-26  4:22                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-26  6:18                           ` Jean Louis
  2020-12-26  6:44                           ` Byung-Hee HWANG
  0 siblings, 2 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-26  4:22 UTC (permalink / raw)
  To: help-gnu-emacs

Byung-Hee wrote:

>> https://dataswamp.org/~incal/COMP-HIST
>
> Thanks Emanuel^^^ i did add the url in my firefox's bookmark.

No problem :)

Feel free to mail me additional lines to describe the history
of your favorite technology... AND the tech you love to
dislike :)

> Sincerely, Gnus fan Byung-Hee

FYI your name is back to Korean. Maybe that was intentional?
(Yes, I changed the attribution line manually in
this message.)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  4:22                         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-26  6:18                           ` Jean Louis
  2020-12-26  6:33                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-26  6:44                           ` Byung-Hee HWANG
  1 sibling, 1 reply; 60+ messages in thread
From: Jean Louis @ 2020-12-26  6:18 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-26 07:26]:
> Byung-Hee wrote:
> 
> >> https://dataswamp.org/~incal/COMP-HIST
> >
> > Thanks Emanuel^^^ i did add the url in my firefox's bookmark.
> 
> No problem :)
> 
> Feel free to mail me additional lines to describe the history
> of your favorite technology... AND the tech you love to
> dislike :)

On your history page you totally forgot Ada:
https://en.wikipedia.org/wiki/Ada_Lovelace




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  6:18                           ` Jean Louis
@ 2020-12-26  6:33                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-26  7:07                               ` Christopher Dimech
                                                 ` (2 more replies)
  0 siblings, 3 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-26  6:33 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> On your history page you totally forgot Ada:
> https://en.wikipedia.org/wiki/Ada_Lovelace

Nope,

  Ada         1980 US military software unifying attempt

line 27, https://dataswamp.org/~incal/COMP-HIST

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  4:22                         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-26  6:18                           ` Jean Louis
@ 2020-12-26  6:44                           ` Byung-Hee HWANG
  1 sibling, 0 replies; 60+ messages in thread
From: Byung-Hee HWANG @ 2020-12-26  6:44 UTC (permalink / raw)
  To: help-gnu-emacs

> FYI your name is back to Korean. Maybe that was intentional?
> (Yes, I changed the attribution line manually in
> this message.)

Oh thanks for the spot! A few minutes ago, i did make some change [1].

[1]
https://gitlab.com/soyeomul/Gnus/-/commit/41655e2f238cda1fa0bb59adaf412ae05d579fe3

Sincerely, Gnus fan Byung-Hee

-- 
^고맙습니다 _和合團結_ 감사합니다_^))//



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  6:33                             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-26  7:07                               ` Christopher Dimech
  2020-12-26  9:53                               ` Jean Louis
  2020-12-26  9:53                               ` Jean Louis
  2 siblings, 0 replies; 60+ messages in thread
From: Christopher Dimech @ 2020-12-26  7:07 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs


Discord 2015 - The trend by the community of socialists

---------------------
Christopher Dimech
General Administrator - Naiad Informatics - GNU Project (Geocomputation)
- Geophysical Simulation
- Geological Subsurface Mapping
- Disaster Preparedness and Mitigation
- Natural Resource Exploration and Production
- Free Software Advocacy


> Sent: Saturday, December 26, 2020 at 12:03 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: let, let*, oh, why [was: Elisp - Function returning a list]
>
> Jean Louis wrote:
>
> > On your history page you totally forgot Ada:
> > https://en.wikipedia.org/wiki/Ada_Lovelace
>
> Nope,
>
>   Ada         1980 US military software unifying attempt
>
> line 27, https://dataswamp.org/~incal/COMP-HIST
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  6:33                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-26  7:07                               ` Christopher Dimech
@ 2020-12-26  9:53                               ` Jean Louis
  2020-12-26 10:11                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-26  9:53                               ` Jean Louis
  2 siblings, 1 reply; 60+ messages in thread
From: Jean Louis @ 2020-12-26  9:53 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-26 09:33]:
> Jean Louis wrote:
> 
> > On your history page you totally forgot Ada:
> > https://en.wikipedia.org/wiki/Ada_Lovelace
> 
> Nope,
> 
>   Ada         1980 US military software unifying attempt

That is maybe programming language Ada, but not Ada Lovelace. Then
what about https://en.wikipedia.org/wiki/Charles_Babbage who is father
of computers?




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  6:33                             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-26  7:07                               ` Christopher Dimech
  2020-12-26  9:53                               ` Jean Louis
@ 2020-12-26  9:53                               ` Jean Louis
  2020-12-26 10:20                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 60+ messages in thread
From: Jean Louis @ 2020-12-26  9:53 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-12-26 09:33]:
> Jean Louis wrote:
> 
> > On your history page you totally forgot Ada:
> > https://en.wikipedia.org/wiki/Ada_Lovelace
> 
> Nope,
> 
>   Ada         1980 US military software unifying attempt
> 
> line 27, https://dataswamp.org/~incal/COMP-HIST

And you could make a nice Emacs package with that list where users
could be presented a list of resources and could get more references
to each of those.




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  9:53                               ` Jean Louis
@ 2020-12-26 10:11                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-26 10:11 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> That is maybe programming language Ada, but not Ada
> Lovelace. Then what about
> https://en.wikipedia.org/wiki/Charles_Babbage who is father
> of computers?

There have always been mechanical machines to do counting...
most likely there were such devices and solutions even during
the stone age! Only they are long lost because they were made
out of wood.

And if you don't have a computer, and can't build one for
practical reasons, one can always do a theoretical model like
Alan Turing and have them execute for arbitrary/sound input,
only then, one has to do computation by hand.

Oh no, computer age year zero is 1947, USA, the transistor.

Or more exactly, 1947-12-23. [1]

$ time-from 1947-12-23 # [2]
73y 3d

[1] https://www.aps.org/publications/apsnews/200011/history.cfm

[2] https://dataswamp.org/~incal/conf/.zsh/time

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26  9:53                               ` Jean Louis
@ 2020-12-26 10:20                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-27  9:11                                   ` Byung-Hee HWANG
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-26 10:20 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> https://dataswamp.org/~incal/COMP-HIST
>
> And you could make a nice Emacs package with that list where
> users could be presented a list of resources and could get
> more references to each of those.

Well, that list is just because I love computer history, text
files, and lists. [1]

I have written a toy IRC bot in Python [2] where you can run
a 'hist' command [3] with a technology or programming language
as argument and then it will answer with that line, if found.

So while I think it is fun and cool, for actual usefulness and
information retrieval any such systems will fail in
competition with the WWW... It is just programming and lists
for their own sake.

But of course, feel free to do whatever with it :)

[1] https://dataswamp.org/~incal/HYPERLIST

[2] https://dataswamp.org/~incal/#bot

[3] https://dataswamp.org/~incal/bot/scripts/hist

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-26 10:20                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-27  9:11                                   ` Byung-Hee HWANG
  2020-12-27 11:52                                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 60+ messages in thread
From: Byung-Hee HWANG @ 2020-12-27  9:11 UTC (permalink / raw)
  To: help-gnu-emacs

> But of course, feel free to do whatever with it :)
>
> [1] https://dataswamp.org/~incal/HYPERLIST
> [2] https://dataswamp.org/~incal/#bot
> [3] https://dataswamp.org/~incal/bot/scripts/hist

Wow Emanuel you Python3 code(sth.py) so cool! AMAZING!!!

Sincerely, Gnus fan Byung-Hee

-- 
^고맙습니다 _地平天成_ 감사합니다_^))//



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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-27  9:11                                   ` Byung-Hee HWANG
@ 2020-12-27 11:52                                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-27 11:56                                       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-27 11:52 UTC (permalink / raw)
  To: help-gnu-emacs

Byung-Hee HWANG wrote:

>> But of course, feel free to do whatever with it :)
>>
>> [1] https://dataswamp.org/~incal/HYPERLIST
>> [2] https://dataswamp.org/~incal/#bot
>> [3] https://dataswamp.org/~incal/bot/scripts/hist
>
> Wow Emanuel you Python3 code(sth.py) so cool! AMAZING!!!
>
> Sincerely, Gnus fan Byung-Hee

Well, thank you Hwang. But I'm sure there is some Python pro
reading this who thinks that code stinks. Normally I always
encourage people to listen to the pros, but in this case, let's
settle for "the truth is somewhere in between" :)

Development is Python is very, very fast. Speaking of the
pros, I don't even dare think how fast they develop in Python.

As for the coolness and beauty, well, compare...

Python:

__version__ = time.strftime('%Y-%m-%d', time.gmtime(os.path.getmtime(pathlib.Path(__file__).absolute())))

Lisp:

(defvar bot-version)
(setq bot-version (format-time-string "%Y-%m-%dT%H:%M:%S"
                   (nth 5 (file-attributes buffer-file-name)) ))

eheh

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: let, let*, oh, why [was: Elisp - Function returning a list]
  2020-12-27 11:52                                     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-27 11:56                                       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-27 11:56 UTC (permalink / raw)
  To: help-gnu-emacs

> (defvar bot-version)
> (setq bot-version (format-time-string "%Y-%m-%dT%H:%M:%S"
>                    (nth 5 (file-attributes buffer-file-name)) ))

Maybe better:

(defvar bot-version)
(setq bot-version (format-time-string
                   "%Y-%m-%dT%H:%M:%S"
                   (file-attribute-modification-time
                    (file-attributes (buffer-file-name)) )))

Hm, actually in this case the Lisp isn't cool either!

OK, just a bad example :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

end of thread, other threads:[~2020-12-27 11:56 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-16  3:25 Elisp - Function returning a list steve-humphreys
2020-12-16  4:09 ` Jean Louis
2020-12-16  4:17   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  5:04     ` steve-humphreys
2020-12-16  5:39       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  7:36         ` steve-humphreys
2020-12-16  8:55           ` Joost Kremers
2020-12-16 10:25           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16 11:52           ` let, let*, oh, why [was: Elisp - Function returning a list] tomas
2020-12-16 14:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16 15:10               ` Jean Louis
2020-12-16 15:58                 ` Stefan Monnier
2020-12-16 18:37                   ` Jean Louis
2020-12-16 19:04                     ` Stefan Monnier
2020-12-16 20:05                       ` Jean Louis
2020-12-16 20:34                         ` tomas
2020-12-16 20:06                       ` tomas
2020-12-18 15:08                       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-18 14:27                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-18 17:42                   ` Jean Louis
2020-12-18 20:57                     ` Eli Zaretskii
2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-20  5:06                       ` Thien-Thi Nguyen
2020-12-20  7:02                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-20  7:16                           ` Thien-Thi Nguyen
2020-12-21  2:34                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-20 13:38                           ` Jean Louis
2020-12-20  6:21                       ` Jean Louis
2020-12-20 23:20                       ` Drew Adams
2020-12-21  4:50                         ` Jean Louis
2020-12-21  5:40                           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-21  9:17                             ` tomas
2020-12-21 15:20                               ` Drew Adams
2020-12-21 15:50                                 ` tomas
2020-12-25 14:41                       ` 황병희
2020-12-26  4:22                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  6:18                           ` Jean Louis
2020-12-26  6:33                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  7:07                               ` Christopher Dimech
2020-12-26  9:53                               ` Jean Louis
2020-12-26 10:11                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  9:53                               ` Jean Louis
2020-12-26 10:20                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-27  9:11                                   ` Byung-Hee HWANG
2020-12-27 11:52                                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-27 11:56                                       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  6:44                           ` Byung-Hee HWANG
2020-12-16  4:30   ` Elisp - Function returning a list steve-humphreys
2020-12-16  4:38     ` Yuri Khan
2020-12-16  4:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  5:20         ` steve-humphreys
2020-12-16  5:18       ` steve-humphreys
2020-12-16  5:33       ` Jean Louis
2020-12-16  5:42         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  8:01           ` Elisp - Function returning a sequence of times Jean Louis
2020-12-16  9:05             ` steve-humphreys
2020-12-16  9:20               ` Joost Kremers
2020-12-16  9:40                 ` steve-humphreys
2020-12-16 21:54             ` Michael Heerdegen
2020-12-16  4:13 ` Elisp - Function returning a list Emanuel Berg via Users list for the GNU Emacs text editor

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.