emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: Help with my first elisp
@ 2022-05-24 17:30 Kepa Diez
  2022-05-24 17:32 ` Fwd: " Ypo
  2022-05-25  6:35 ` Orm Finnendahl
  0 siblings, 2 replies; 12+ messages in thread
From: Kepa Diez @ 2022-05-24 17:30 UTC (permalink / raw)
  To: Org-mode

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


> maybe use something like
>
> >/> (define-key mh-letter-mode-map/
> >/> (kbd "C-c s")/
> >/> 'ggm-mh-sentaddrs-completion)/
>
> but, using whatever the name of the logos-focus mode map, pointing at
> your functions?

Hi Greg

I think "logos" doesn't have a map, is it possible?


> On Mon, May 23, 2022 at 09:46:09AM -0700, Greg Minshall wrote:
> >/Ypo,/
> >//
> >/> (defun salto ()/
> >/> (interactive)/
> >/> (if posicion 1/
>
> You are comparing the value of posicion to 1?
>
> Then it should probably be "(if (= posicion 1) ...)" or
> "(if (equal posicion 1) ...)" or something like that.
>
> Cheers
> -- 
> t
Thanks, Tomas. It seems the "if" part works, now I use my elisp just 
with the spacebar :-)

(add-hook 'logos-focus-mode-hook #'(lambda ()

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

   (defun focusPointStart ()
   (interactive)
   (next-line 1)
   (beginning-of-visual-line)
   (forward-char 6)
   (setq posicion 1)
)

(defun focusPointInter ()
   (interactive)
   (forward-char 23)
   (setq posicion 2)
)


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

(defun focusJump ()
   (interactive)
   (if (equal posicion 1)
     (focusPointInter)
       (if (equal posicion 2)
       (focusPointEnd)
         (if  (equal posicion 3)
         (focusPointStart)))))

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


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

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Help with my first elisp
@ 2022-05-22 11:37 Ypo
  2022-05-22 13:27 ` Greg Minshall
  0 siblings, 1 reply; 12+ messages in thread
From: Ypo @ 2022-05-22 11:37 UTC (permalink / raw)
  To: Org-mode

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

Hi


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.

https://protesilaos.com/codelog/2022-01-31-learning-emacs/
(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:

https://www.tiktok.com/@yporg/video/7100510074342280454?is_from_webapp=1&sender_device=pc&web_id=7100507416085399046


My problems:

  * I don't know how to make my code work always and only when in
    logos-mode.
  * 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 ()
   (interactive)
   (next-line 1)
   (beginning-of-visual-line)
   (forward-char 6)
)


(defun posicion2 ()
   (interactive)
   (forward-char 23)
)


(defun posicion3 ()
   (interactive)
   (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 ()
   (interactive)
   (next-line 1)
   (beginning-of-visual-line)
   (forward-char 6)
   (setq posicion 1)
)


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


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




(defun salto ()
   (interactive)
   (if posicion 1
     (posicion2))
   (if posicion 2
     (posicion3))
   (if posicion 3
     (posicion1))
)

(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 --]

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

end of thread, other threads:[~2022-05-27  7:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 17:30 Help with my first elisp Kepa Diez
2022-05-24 17:32 ` Fwd: " Ypo
2022-05-24 18:16   ` tomas
2022-05-25  4:55   ` Greg Minshall
2022-05-25  6:35 ` Orm Finnendahl
2022-05-25  8:24   ` tomas
2022-05-27  7:23     ` Orm Finnendahl
  -- strict thread matches above, loose matches on Subject: below --
2022-05-22 11:37 Ypo
2022-05-22 13:27 ` Greg Minshall
2022-05-22 14:18   ` Ypo
2022-05-23 16:46     ` Greg Minshall
2022-05-23 19:38       ` tomas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).