all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Noam Postavsky <npostavs@gmail.com>, Christopher Dimech <dimech@gmx.com>
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: RE: Cycle Org Shift Select
Date: Wed, 11 Nov 2020 09:09:25 -0800 (PST)	[thread overview]
Message-ID: <fe8e399d-7c01-4a20-8ddf-adcc5b63b859@default> (raw)
In-Reply-To: <dbbb4f43-594a-4563-9525-fd99526b6b60@default>

> > (defun Org-Shftsel-Cycle ()
> >   (interactive)
> >   (setq org-support-shift-select
> >         (cadr (memq org-support-shift-select '(nil t always nil)))))
> 
> Elegant Lisp, IMO!  A good idiom.
> ___
> 
> 
> Slightly cuter: the last nil isn't needed, since (car nil) = nil.
> 
> (defvar toto nil)
> 
> (defun foo ()
>   (interactive)
>   (setq toto  (cadr (memq toto '(nil t always))))
>   (message "NOW: %s" toto))
> 
> Of if you want to show also what'll come next:
> 
> (defun foo ()
>   (interactive)
>   (let ((xs  '(nil t always))
>         next)
>     (setq toto  (cadr (memq toto xs))
>           next  (cadr (memq toto xs)))
>     (message "NOW: %s, NEXT: %s" toto next)))

On the other hand, if you want to be able to go either
forward or backward then you might want to use a ring
(as defined in standard library ring.el):

(defvar ring (ring-convert-sequence-to-ring '(nil t always)))
(defvar current nil)

(defun next ()
  (interactive)
  (setq current  (ring-next toto current))
  (message "NOW: %s" current))

(defun previous ()
  (interactive)
  (setq current  (ring-previous toto current))
  (message "NOW: %s" current))



  reply	other threads:[~2020-11-11 17:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06 15:23 Cycle Org Shift Select Christopher Dimech
2020-11-09 19:12 ` Noam Postavsky
2020-11-09 20:13   ` Michael Heerdegen
2020-11-09 20:26     ` Noam Postavsky
2020-11-09 20:31       ` Michael Heerdegen
2020-11-09 20:37         ` Noam Postavsky
2020-11-09 21:08           ` Michael Heerdegen
2020-11-09 21:19             ` Noam Postavsky
2020-11-09 20:40     ` Christopher Dimech
2020-11-09 20:42       ` Noam Postavsky
2020-11-09 20:52         ` Christopher Dimech
2020-11-09 20:53           ` Noam Postavsky
2020-11-09 21:20             ` Michael Heerdegen
2020-11-09 21:25               ` Noam Postavsky
2020-11-09 21:36                 ` Michael Heerdegen
2020-11-09 21:45             ` Christopher Dimech
2020-11-09 21:49               ` Noam Postavsky
2020-11-09 21:50               ` Michael Heerdegen
2020-11-09 21:59                 ` Christopher Dimech
2020-11-09 22:49       ` Christopher Dimech
2020-11-10  8:08         ` tomas
2020-11-10 10:17           ` Christopher Dimech
2020-11-10 11:10             ` Michael Heerdegen
2020-11-10 16:37   ` Drew Adams
2020-11-11 17:09     ` Drew Adams [this message]
2020-11-09 20:10 ` Michael Heerdegen
2020-11-09 20:35   ` Christopher Dimech
2020-11-09 21:18     ` Michael Heerdegen

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=fe8e399d-7c01-4a20-8ddf-adcc5b63b859@default \
    --to=drew.adams@oracle.com \
    --cc=dimech@gmx.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=npostavs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.