From: Emanuel Berg via help-gnu-emacs <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: complicated code to do trivial (?) thing
Date: Wed, 12 Jun 2019 01:50:06 +0200 [thread overview]
Message-ID: <865zpby95d.fsf@zoho.eu> (raw)
Why isn't this easy to do?
Or is it?
;;; -*- lexical-binding: t -*-
;; This file: http://user.it.uu.se/~embe8573/emacs-init/abc.el
;; https://dataswamp.org/~incal/emacs-init/abc.el
(require 'cl-lib)
(defun alphabet (&optional as-list)
(let ((abc "a b c d e f g h i j k l m n o p q r s t u v w x y z"))
(if as-list
(cl-remove ?\ (string-to-list abc))
abc
)))
;; (alphabet t) ; (97 98 99 100 101 102 103 104 105 106 107 ...)
;; (alphabet) ; "a b c d e f g h i j k ..."
(defun echo-alphabet (&optional number)
(interactive "P")
(let*((num (or number (length (alphabet t))))
(part (cl-subseq (alphabet t) 0 num))
(str-list (cl-mapcar (lambda (c) (char-to-string c)) part))
(str-almost (format "%s" str-list))
(str (substring str-almost 1 (1- (length str-almost))))
)
(message str) ))
;; (echo-alphabet) ; "a b c ... x y z"
;; (echo-alphabet 10) ; "a b c d e f g h i j"
;; (echo-alphabet -10) ; "a b c d e f g h i j k l m n o p"
;; (call-interactively #'echo-alphabet)
(defalias 'abc #'echo-alphabet)
(provide 'abc)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
next reply other threads:[~2019-06-11 23:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-11 23:50 Emanuel Berg via help-gnu-emacs [this message]
2019-06-12 7:16 ` complicated code to do trivial (?) thing Anders Dalskov
2019-06-14 19:41 ` Emanuel Berg via help-gnu-emacs
2019-07-10 0:08 ` Emanuel Berg via help-gnu-emacs
2019-07-10 8:11 ` Anders Dalskov
2019-07-10 8:59 ` Emanuel Berg via help-gnu-emacs
2019-07-10 9:34 ` tomas
-- strict thread matches above, loose matches on Subject: below --
2019-07-10 17:34 Joe Trivers via help-gnu-emacs
2019-07-10 18:10 ` Joe Trivers via help-gnu-emacs
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=865zpby95d.fsf@zoho.eu \
--to=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/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.