From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CG3TJfx6r2FJLQAAgWs5BA (envelope-from ) for ; Tue, 07 Dec 2021 16:17:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id kGGIIfx6r2FGPAAA1q6Kng (envelope-from ) for ; Tue, 07 Dec 2021 15:17: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 591BA27EBA for ; Tue, 7 Dec 2021 16:17:15 +0100 (CET) Received: from localhost ([::1]:41086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mucDR-0004k7-AB for larch@yhetil.org; Tue, 07 Dec 2021 10:17:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mucCt-0004ju-Br for emacs-orgmode@gnu.org; Tue, 07 Dec 2021 10:16:39 -0500 Received: from [2607:f8b0:4864:20::42f] (port=44829 helo=mail-pf1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mucCn-0002b7-CL for emacs-orgmode@gnu.org; Tue, 07 Dec 2021 10:16:39 -0500 Received: by mail-pf1-x42f.google.com with SMTP id k64so5606081pfd.11 for ; Tue, 07 Dec 2021 07:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=pIOyeXLcwXVcDCa/+ie1IcHTBu1/bOeWOOe9++zxCsg=; b=nnetNF/LvJVcoFb0wY6a+GU+OHqgJC+o5bKwgx5aPjQ7I833WaxEa6lVR3nbJQp3Fi Cf/FwdRtv17b/c7jUNHFCwpewF3L0ooRSkkyei0NvuH1Yxc4uVj0aI/Za15yo8k0xSZF 8egsaf1UnNhufNde31G5Qdy7JDCBDl2WdxMzDeWYywI182TPSjKpnJS0fJAkcpD3WkPd BwHMC8PKoNanTUyK3Iy9yISLLORjCIRx6XJ7oY3kzdOQFhMa8ndyuyrHvHh8lkGfYIEc CVzOAI16n0i9ZQv3UvkkwNcA/X6AP9ckZ4QVxyyV56TezJvv55cGQznVusMxldDsNfQR IZuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=pIOyeXLcwXVcDCa/+ie1IcHTBu1/bOeWOOe9++zxCsg=; b=MWGY6js7ibsPidxCbMtYv2nqWMP0GCRkNpbsaOuOmTnHlTNiwyHtD2PTlkaRJ8F2w2 S+w+DHopZqOVWsP1M9iSAz6/instDXFhbj9zmoeg+P6qCBkVyKgzHNypQNmscjxtmmRe I+BYUwgJEzHcDm01l9zW/k+k0LUG2CcCQJnHNrSqyx2mvCO3iTZhQ/k9QhGllqVTmpvc fKY9TXgk3N39/Og4dEZYpaDPJFhVRdGEDCvYukBMEzXVDvoKTvOYyBD9fkwnmwC4/78Q 3s0LeTYAbqjOsX1WglXZ5ngMUNBq0U9PuFvTsczggBODN/AkrZRntSfJMOVTiIbzvIJ3 zVMA== X-Gm-Message-State: AOAM530jVpiIuhNWEHdPy/zq1HXEqLgeWJo3L/Kd+HoiG3mLwTcWyl3G ivI/XLzw+9COR0U5Vl2Dt8cBV92EZ7agMm9J7o8= X-Google-Smtp-Source: ABdhPJypnKone47jWgMcF8DR9Ed/MO8mAkN7KHJMijUmhjYOesm1+muGpbfdkJDqTQo+zzMWfG23RWYfIOlyTlpticA= X-Received: by 2002:a05:6a00:99b:b0:49f:eab4:4e7e with SMTP id u27-20020a056a00099b00b0049feab44e7emr43428208pfg.63.1638890191869; Tue, 07 Dec 2021 07:16:31 -0800 (PST) MIME-Version: 1.0 References: <5b93e27d-df22-3799-7b35-3078472a5154@gmail.com> <61a37784-cdac-4044-1223-2a8bf45ac8e5@gmail.com> In-Reply-To: <61a37784-cdac-4044-1223-2a8bf45ac8e5@gmail.com> From: Eduardo Ochs Date: Tue, 7 Dec 2021 12:16:20 -0300 Message-ID: Subject: Re: From macros to elisp programming? To: Ypo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=eduardoochs@gmail.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=no 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=1638890235; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=pIOyeXLcwXVcDCa/+ie1IcHTBu1/bOeWOOe9++zxCsg=; b=BD8WCBEXFlllJRF2aEl5G3Z6TB7oIYqrQt48AgkyDsFYtJ91cWWSKPkfRmwXE67xQWT3/k eEjMblB0Y/BitxkWFgn5ZXQjZw+bDojbgCj2EJfqN9we7vQbNEDkmBFimHQrl1JCtPzs0W UUeVs13UB47ZLguIymtP3U3KkD2Vop0q2QspSxQTytf2A3XQ/eWPBMqdek8GBP5dnrQOCB gBp8pnx2tYmrMUM0eoi1L+oGeoFiUL7tL8Wlrv9t2oAkHYK9r9xnzCiOjj+FK1zJIEnaU/ fHNpM47OlGIKd9EVogrb8CcYxoBjBRhZUQv/IiH8kNlShDxImPVOa3U7tjBfNA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638890235; a=rsa-sha256; cv=none; b=CLWzuYNCPO0GRfxUlXL8pV4X/mHlD46X4Da/n20fRF3BYmPq5be0mc+g5ZzPPfJpRO0s2V yk+r2OZ4ZIg1F7qo5zAbIZFShMGoeZr1vx4+NE9B62gVYbOtVkOfk5MhsBvSK92bTSdrPe 8FWJSkgQJ+WT2ezUXE9yuQ7DxTqMV9EUYIs1GdS5bo8e9w6NN+nJNwVLvh+5uyOZ2nNvJU Hk05sBGOrtuMSi6sBQpeWIGwkS5tMR6zZSArgLVwRyf/9s90Q4dNVO8kQ7SwuVlNG+EJ9O mIWedM6IdUBGynOVqE+rlaeIzpuRelV2/Dueff+lNVpRCOBFgcrkI98C1YBSFw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="nnetNF/L"; 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="nnetNF/L"; 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: 591BA27EBA X-Spam-Score: -3.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3kycyD77PPgC Hi Ypo! You may find this useful too. I often use it when I want to put editing commands in my functions and I'm in a hurry and not in a mood to find their names - so for example I use (eek "C-l") instead of (recenter-top-bottom), or (eek " C-a C-SPC M-w C-y") to duplicate the line above the point... Cheers & happy hacking =3D), E. http://angg.twu.net/#eev ;; See: ;; http://angg.twu.net/eev-intros/find-eev-quick-intro.html#3 ;; (find-eev-quick-intro "3. Elisp hyperlinks") ;; (defun eek (str) "Execute STR as a keyboard macro. See `edmacro-mode' for the exact format= .\n An example: (eek \"C-x 4 C-h\")" (interactive "sKeys: ") (execute-kbd-macro (read-kbd-macro str))) On Tue, 7 Dec 2021 at 09:55, Ypo wrote: > > 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=C3=BAde! > > > El 07/12/2021 a las 3:11, Eduardo Ochs escribi=C3=B3: > > 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=C3=A9ndez = Bala=C3=B1a" (pp. 95-118) > **** INTRODUCCI=C3=93N > > I get modified the second headline: > > *** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos, Men=C3=A9ndez = Bala=C3=B1a" (pp. 95-118) > **** Sanz Aparicio et al. (2019) "5 Los Motivos Adquiridos - INTRODUCCI= =C3=93N" > > > 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! =3D) - 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 =3D), > Eduardo Ochs > http://angg.twu.net/#eev