From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0PrfHfBZr2H+OgEAgWs5BA (envelope-from ) for ; Tue, 07 Dec 2021 13:56:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id CMyjGfBZr2ElXgAA1q6Kng (envelope-from ) for ; Tue, 07 Dec 2021 12:56:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E691336E67 for ; Tue, 7 Dec 2021 13:56:15 +0100 (CET) Received: from localhost ([::1]:33508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mua11-0007Ae-2w for larch@yhetil.org; Tue, 07 Dec 2021 07:56:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mua0T-0007AQ-OP for emacs-orgmode@gnu.org; Tue, 07 Dec 2021 07:55:41 -0500 Received: from [2a00:1450:4864:20::42c] (port=40717 helo=mail-wr1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mua0R-0002qj-Ng for emacs-orgmode@gnu.org; Tue, 07 Dec 2021 07:55:41 -0500 Received: by mail-wr1-x42c.google.com with SMTP id t9so29259698wrx.7 for ; Tue, 07 Dec 2021 04:55:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to; bh=Yj30HIVTxNM+q+tgMwmch7OJvlpTLkMKh7EDe6cVosY=; b=Q2gE0rK2zk1VSdz18licm4HVhUufSFsf1BxzCPwpjKWvd5RYErcXp+GrTI1DE/mSiN FZXsLOfrBqDzjP86rhiit9mD5fdk+biSLVfCaP4eRpi20ekwb4vuz8G9uJJsQdOtAgUK ++rpNX77jnDbBnYjqlzhq4we1K5GDR/3tIiILm1nNu+U4ytO3snpavPM/9kF4Qx3dZVM 7hFi6btXJPjPPGwgzTPKxaih3N/ZdCqE4rOhTc1nOxqbjLKI7OnIxqT9myVPP/oppkL3 3oerF1J4/5DXqiB/bjJFdOAemUCwTKGfsFodXXzFhafVxoxy36gIuauFGswB/ibC+f+y wdPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to; bh=Yj30HIVTxNM+q+tgMwmch7OJvlpTLkMKh7EDe6cVosY=; b=BkJYkgGAGnc4U9cJb4eqz5kd9DQdYZqe9+AhkWEer5rwk9vIjNszLR78T1uc4+GR2s 4X3kXfAk+Pj3PP2sfA7w/6fD33y4fdy/a5oQc8E4rAORl/NNwmmSYq40UGJu+vayEJ3B dIkmHqkadYBzRZDpfgY7WHoi+LG+akCYRVjHNCPXtep04Gp8imXVKzbJATz3MpHWPA/z f1u8RZbdSqcS0R2Kx0p1oaTHplGd2Q33cAy8rHQxiv8XulxywT3a3rLtTfDBHAskkk91 n/BnqoEBv8oa8TO1l7vOceONO7YcM2Lve8tUv0uVGjfDFaIJoNOjFjBWK7OlkiGYvpvU Vhng== X-Gm-Message-State: AOAM532fslpg6k22Zpp7Up3+Ms669k3PxmlwujU1uapFo0lApS53F25K iGzIwCQqNnswzeXkIYR10JE= X-Google-Smtp-Source: ABdhPJwWV1oY6CalTp0vXe9/tu6tmGP1PeNl4/+rH6imuzWUHIacuABEQG8IBDDSnM5Kb2ULDJFwVQ== X-Received: by 2002:a05:6000:18ad:: with SMTP id b13mr52972764wri.195.1638881737703; Tue, 07 Dec 2021 04:55:37 -0800 (PST) Received: from [192.168.0.97] (static-210-200-229-77.ipcom.comunitel.net. [77.229.200.210]) by smtp.gmail.com with ESMTPSA id u23sm15489031wru.21.2021.12.07.04.55.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Dec 2021 04:55:37 -0800 (PST) Content-Type: multipart/alternative; boundary="------------PzRKB8d8AEmcSQ5Ig0RRa0t3" Message-ID: <61a37784-cdac-4044-1223-2a8bf45ac8e5@gmail.com> Date: Tue, 7 Dec 2021 13:55:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: From macros to elisp programming? Content-Language: en-GB To: Eduardo Ochs References: <5b93e27d-df22-3799-7b35-3078472a5154@gmail.com> From: Ypo In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=ypuntot@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -36 X-Spam_score: -3.7 X-Spam_bar: --- X-Spam_report: (-3.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, NICE_REPLY_A=-2.44, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org-mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1638881776; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Yj30HIVTxNM+q+tgMwmch7OJvlpTLkMKh7EDe6cVosY=; b=eIoleTr41tE9W/YBJSHU74+/1KVz2mwvfnyxsTbr1oPVcCygjizqRxMeprZgglofPXNEtF fRR9/TyPFYyXM6u/BAtiVSR4XjavXIWx2zxjxqMd+HuPPSy6K5zImIRXT59mW+bf2YiXRI M/tnIMpIOa+BeJpvBUU2h5vEwWp/l029LEG8LRKpiSUjfik32Iahp+4Y4HBcKZ1LHgF1V3 e5Es4yMPT0si8iVLsvlBfY6rhz4Wu7G1XlXHpbSTFpDsU9X0VzHbAUDkITqxraPq7SrKzf sFL/oaD6OOztHOSPa65aGWingP70tKYsPVDOUZf9kkvHK0ulwwIAsyiBRARQuw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638881776; a=rsa-sha256; cv=none; b=lxObJac+B/VZGxIBINEm6s+dQ5GaxlxCIgqk0J54M6MDSwF2ugnUa9rkr2xYVrMeMbLqUD 7AYgoJ+hJnPKQEvmLcrVo93r7NBPUg29mEIORExDVDL7vnau04vkk9Xs2xf2gvtyigp1u9 3vHOABUOyQ2ngBnlznmUWAy78qeldMSc08mYZH5IjAF/WqckPI5Yv8xWm28ud1q0+y7HMx zIdgtZ1oFgs2AOakW3vmpbEEpeWLG5m7DQOG36ePniDZL5yLsfFAkc6TLVATDrxf7+ydUP pymtE82xTCQ94InAl573SE2RxWU5ety0FHuhNqQ9XOMNyGjvLrqPO5P9FPfT7A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Q2gE0rK2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Q2gE0rK2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E691336E67 X-Spam-Score: -3.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: VEZ64x/BY0yH This is a multi-part message in MIME format. --------------PzRKB8d8AEmcSQ5Ig0RRa0t3 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Obrigado, Eduardo! I didn't know that command: "setq last-kbd-macro" and probably it will be useful with elmacro too. (outline-next-visible-heading) ;; C-c C-n I save your instructions to my notes to use them :-) Saúde! El 07/12/2021 a las 3:11, Eduardo Ochs escribió: > On Mon, 6 Dec 2021 at 10:43, Ypo wrote: >> Hi >> >> I am able to make macros, but I think I am far away from Lisp programming. >> >> Is there a path to go from macros to elisp programming? For example, the last macro I've made is for transforming the name of some headlines, adding in front of them a part from the previous headline. This is the elisp code of the macro: >> >> #+BEGIN_SRC >> (fset 'SanzTema5 >> (kmacro-lambda-form [?\C-a ?\M-f ?\M-b ?\C- ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-w ?\C-c ?\C-n ?\C-a ?\M-f ?\M-b ?\C-y ? ?- ? ?\C-e ?\M-b ?\M-f ?\"] 0 "%d")) >> #+END_SRC >> >> >> Using that code, from these headlines: >> >> *** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos, Menéndez Balaña" (pp. 95-118) >> **** INTRODUCCIÓN >> >> I get modified the second headline: >> >> *** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos, Menéndez Balaña" (pp. 95-118) >> **** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos - INTRODUCCIÓN" >> >> >> Are macros near to elisp programming or they are two different worlds? >> >> Ypo > > Hi Ypo, > > here's a suggestion. If you run this > > (setq last-kbd-macro [?\C-a ?\M-f ?\M-b ?\C- ?\M-f ?\M-f ?\M-f ?\M-f > ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-w ?\C-c ?\C-n ?\C-a ?\M-f ?\M-b > ?\C-y ? ?- ? ?\C-e ?\M-b ?\M-f ?\"]) > > and then type `C-x C-k C-e' (`kmacro-edit-macro-repeat') you will get > a temporary buffer that contains this: > > C-a ;; move-beginning-of-line > M-f ;; forward-word > M-b ;; backward-word > C-SPC ;; set-mark-command > 9*M-f ;; forward-word > M-w ;; kill-ring-save > C-c C-n > C-a ;; move-beginning-of-line > M-f ;; forward-word > M-b ;; backward-word > C-y ;; yank > SPC ;; self-insert-command > - ;; self-insert-command > SPC ;; self-insert-command > C-e ;; move-end-of-line > M-b ;; backward-word > M-f ;; forward-word > " ;; self-insert-command > > If you convert that by hand - suggestion: use keyboard macros for > that! =) - to a defun like this one, > > (defun SanzTema5 () > (interactive) > (move-beginning-of-line) ; C-a > (forward-word) ; M-f > (backward-word) ; M-b > (set-mark-command) ; C-SPC > (dotimes 9 (forward-word)) ; 9*M-f > ;; ^ or: (forward-word 9) > (kill-ring-save) ; M-w > ;; What here? I don' have a: ; C-c C-n > (move-beginning-of-line) ; C-a > (forward-word) ; M-f > (backward-word) ; M-b > (yank) ; C-y > (insert " - ") ; SPC - SPC > (move-end-of-line) ; C-e > (backward-word) ; M-b > (forward-word) ; M-f > (insert "\"") ; " > ) > > Then you will get a defun that does something that is clearly useful > to you... you can start by creating and debugging a handful of defuns > like that one and then learn what most people consider as "real > Elisp"... > > Cheers =), > Eduardo Ochs > http://angg.twu.net/#eev --------------PzRKB8d8AEmcSQ5Ig0RRa0t3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Obrigado, Eduardo!

I didn't know that command: "setq last-kbd-macro" and probably it will be useful with elmacro too.

(outline-next-visible-heading) ;; C-c C-n

I save your instructions to my notes to use them :-)

Saúde!


El 07/12/2021 a las 3:11, Eduardo Ochs escribió:
On Mon, 6 Dec 2021 at 10:43, Ypo <ypuntot@gmail.com> wrote:
Hi

I am able to make macros, but I think I am far away from Lisp programming.

Is there a path to go from macros to elisp programming? For example, the last macro I've made is for transforming the name of some headlines, adding in front of them a part from the previous headline. This is the elisp code of the macro:

#+BEGIN_SRC
(fset 'SanzTema5
   (kmacro-lambda-form [?\C-a ?\M-f ?\M-b ?\C-  ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-w ?\C-c ?\C-n ?\C-a ?\M-f ?\M-b ?\C-y ?  ?- ?  ?\C-e ?\M-b ?\M-f ?\"] 0 "%d"))
#+END_SRC


Using that code, from these headlines:

*** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos, Menéndez Balaña" (pp. 95-118)
**** INTRODUCCIÓN

I get modified the second headline:

*** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos, Menéndez Balaña" (pp. 95-118)
**** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos - INTRODUCCIÓN"


Are macros near to elisp programming or they are two different worlds?

Ypo

Hi Ypo,

here's a suggestion. If you run this

  (setq last-kbd-macro [?\C-a ?\M-f ?\M-b ?\C- ?\M-f ?\M-f ?\M-f ?\M-f
    ?\M-f ?\M-f ?\M-f ?\M-f ?\M-f ?\M-w ?\C-c ?\C-n ?\C-a ?\M-f ?\M-b
    ?\C-y ? ?- ? ?\C-e ?\M-b ?\M-f ?\"])

and then type `C-x C-k C-e' (`kmacro-edit-macro-repeat') you will get
a temporary buffer that contains this:

    C-a                     ;; move-beginning-of-line
    M-f                     ;; forward-word
    M-b                     ;; backward-word
    C-SPC                   ;; set-mark-command
    9*M-f                   ;; forward-word
    M-w                     ;; kill-ring-save
    C-c C-n
    C-a                     ;; move-beginning-of-line
    M-f                     ;; forward-word
    M-b                     ;; backward-word
    C-y                     ;; yank
    SPC                     ;; self-insert-command
    -                       ;; self-insert-command
    SPC                     ;; self-insert-command
    C-e                     ;; move-end-of-line
    M-b                     ;; backward-word
    M-f                     ;; forward-word
    "                       ;; self-insert-command

If you convert that by hand - suggestion: use keyboard macros for
that! =) - to a defun like this one,

  (defun SanzTema5 ()
    (interactive)
    (move-beginning-of-line)       ; C-a
    (forward-word)                 ; M-f
    (backward-word)                ; M-b
    (set-mark-command)             ; C-SPC
    (dotimes 9 (forward-word))     ; 9*M-f
    ;; ^ or: (forward-word 9)
    (kill-ring-save)               ; M-w
    ;; What here? I don' have a:   ; C-c C-n
    (move-beginning-of-line)       ; C-a
    (forward-word)                 ; M-f
    (backward-word)                ; M-b
    (yank)                         ; C-y
    (insert " - ")                 ; SPC - SPC
    (move-end-of-line)             ; C-e
    (backward-word)                ; M-b
    (forward-word)                 ; M-f
    (insert "\"")                  ; "
    )

Then you will get a defun that does something that is clearly useful
to you... you can start by creating and debugging a handful of defuns
like that one and then learn what most people consider as "real
Elisp"...

  Cheers =),
    Eduardo Ochs
    http://angg.twu.net/#eev
--------------PzRKB8d8AEmcSQ5Ig0RRa0t3--