emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ypo <ypuntot@gmail.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: Help with my first elisp
Date: Sun, 22 May 2022 13:37:01 +0200	[thread overview]
Message-ID: <5ca03caa-bb97-664b-4c58-9ec296a1eef8@gmail.com> (raw)

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


After thinking about learning elisp for years, today I've tried my first 
script. First I made some macros that worked as I intended, and then 
using this tutorial of Protesilaos I was able to transform those macros 
into elisp code.

(thanks a lot)

My situation: I am using Protesilaos' package logos, and I would like to 
add to it something (a hook?): to mark the position where my eyesight 
must go. Example:


My problems:

  * I don't know how to make my code work always and only when in
  * I get those jumps pressing 1, 2 and 3. I would like to use just 1
    key (for example SPACEBAR) not 3 keys to run the function.

My code:

(defun posicion1 ()
   (next-line 1)
   (forward-char 6)

(defun posicion2 ()
   (forward-char 23)

(defun posicion3 ()
   (end-of-visual-line) ;;C-e
   (backward-char 7)

(define-key global-map (kbd "1") #'posicion1)
(define-key global-map (kbd "2") #'posicion2)
(define-key global-map (kbd "3") #'posicion3)

Additional problem: I don't know how to recover keys 1, 2 and 3 to their 
normal functioning, right now I can't type 1, 2 or 3 on my Emacs. xD

I think it could be interesting to use just SPC, instead of 1, 2 and 3. 
Maybe it could be done using conditionals, like in this not-working example:

(defvar posicion
   "Position where it is the cursor.")

(defun posicion1 ()
   (next-line 1)
   (forward-char 6)
   (setq posicion 1)

(defun posicion2 ()
   (forward-char 23)
   (setq posicion 2)

(defun posicion3 ()
   (end-of-visual-line) ;;C-e
   (backward-char 7)
   (setq posicion 3)

(defun salto ()
   (if posicion 1
   (if posicion 2
   (if posicion 3

(define-key global-map (kbd "SPC") #'salto)

Any help, advice, warning, or menace are welcome.

Best regards :-)

[-- Attachment #2: Type: text/html, Size: 5896 bytes --]

             reply	other threads:[~2022-05-22 11:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-22 11:37 Ypo [this message]
2022-05-22 13:27 ` Help with my first elisp Greg Minshall
2022-05-22 14:18   ` Ypo
2022-05-23 16:46     ` Greg Minshall
2022-05-23 19:38       ` tomas
  -- strict thread matches above, loose matches on Subject: below --
2022-05-24 17:30 Kepa Diez
2022-05-25  6:35 ` Orm Finnendahl
2022-05-25  8:24   ` tomas
2022-05-27  7:23     ` Orm Finnendahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ca03caa-bb97-664b-4c58-9ec296a1eef8@gmail.com \
    --to=ypuntot@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).