[Top][All Lists]

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

Re: Why eev has a weird elisp tutorial and how to use it

From: Emanuel Berg
Subject: Re: Why eev has a weird elisp tutorial and how to use it
Date: Fri, 28 Jan 2022 03:49:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

  And this video is - hopefully - a first step to make my
  tutorial less mysterious. So: that's it. That's what
  i wanted to show. Bye! =) [1]

Yeah, that was a verbose and informal intro from a personal
POV if there ever was one - and except for the thing I already
mentioned, that people should learn to read code first, where
I disagree 100%, from my POV but also in general - but except
for that, all's cool obviously, but ...

Where is the actual Elisp intro? :O

There's no transcript of that?

That's the one, if one only has one, that one should have!

My own POV is rather different, I think. TBH I don't remember
ever having a problem with Elisp at the early stages actually
... a cheat sheet (crib sheet) with all the basic stuff
(meaning a lot since there is a lot) and on top of that
a cookbook of more advanced, but still common methods and
situations - this OTOH can be commented, tho briefly - those
two documents would have perhaps speeded up early effort.

"Methods and situations" would include small demos and
skeleton code with concepts such as DWIM, closures, stuff like
that, the more Lispy stuff. Nothing a beginner can't handle if
presented right.

Example DWIM:

;;; -*- lexical-binding: t -*-
;;; this file:

;; DWIM interface

(defun test-dwim (&optional beg end)
  (interactive (when (use-region-p)
                 (list (region-beginning) (region-end)) ))
  (let ((bg (or beg (point-min))) ; or just (point) here
        (ed (or end (point-max))) )
    (list bg ed) ; code here

;; test the interface

(when nil
    (set-mark   10)
    (goto-char 500)
    (call-interactively #'test-dwim) ) ; (10  500)
  (call-interactively #'test-dwim)     ; ( 1 1163)
  (test-dwim 30 90)                    ; (30   90)
  (test-dwim)                          ; ( 1 1163)

;; example function

(defun count-chars (&optional beg end)
  (interactive (when (use-region-p)
                 (list (region-beginning) (region-end)) ))
  (let*((bg   (or beg (point-min)))
        (ed   (or end (point-max)))
        (diff (- ed bg)) )
      (message "%d" diff) )))

;; test the example function

;; (call-interactively #'count-chars) ; 1162
;; (count-chars)                      ; 1162
;; (count-chars 10 40)                ; 30
;; (+ 1111 (count-chars))             ; 2273


underground experts united

reply via email to

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