unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: Re: [External] : Re: discoverability, better defaults and which-key in Emacs
Date: Fri, 02 Feb 2024 16:53:51 +0100	[thread overview]
Message-ID: <871q9uamls.fsf@dataswamp.org> (raw)
In-Reply-To: SJ0PR10MB548836A2924114DBA0D83F5BF3422@SJ0PR10MB5488.namprd10.prod.outlook.com

Drew Adams wrote:

>>> I for one would be very interested to know what of my
>>> Elisp I can discard in favor of using stuff in core Emacs.
>>> But I don't have a confident answer how to find out.
>> 
>> Some Emacs commands I suggest for this are:
>>   C-u M-x apropos
>>   M-x apropos-documentation
>>   C-h R elisp RET followed by 'i' (Info-index) and the subject
>
> +1 to all of that.
>
> The most important aid for users - esp. but not only new
> users - is IMHO for them to learn how to better "ask Emacs".

If sorted alphabetically, this is my first Elisp file, abc.el.

After that, the second file, align-from-left.el.

How do I ask Emacs if someone already wrote it and made
it available?

I think part of the problem is before one has programmed it,
it is very difficult to formulate it in an exact way, and one
doesn't always have a clear image what one is doing, even.

I'm not challenging anyone to ask Emacs, rather ... they are
two examples what stuff I have been writing and many, many
times wondered how anyone would ever know, what everyone else
are writing. Someone else must have already written it, right?

Interestingly, it is often easier to find advanced, specialized
stuff than small math and data manipulation functions.
Since they are so general, if one searches, one gets a lot of
hits, a lot of them doing something quite similar but not
exactly the same.

Maybe someone already tried to have Lisp with standard
libraries. Several times?

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   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 ?\s (string-to-list abc))
      abc) ))

;; (alphabet)   ; 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
;; (alphabet t) ; (97 98 99 100 101 102 103 104 105 106 107 108 ...)

(defun echo-alphabet (&optional num)
  (interactive "P")
  (or num (setq num (length (alphabet t))))
  (let*((part       (cl-subseq (alphabet t) 0 num))
        (str-list   (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) ))

(defalias 'abc #'echo-alphabet)

;; (echo-alphabet)     ; 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
;; (echo-alphabet   2) ; a b
;; (echo-alphabet  -2) ; a b c d e f g h i j k l m n o p q r s t u v w x
;; (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

(provide 'abc)

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/align-from-left.el

(require 'cl-lib)

(let ((alf-regexp))
  (defun align-from-left (&optional set-regexp)
    (interactive "p")
    (let ((default-regexp "^\\|[[:punct:]]\\|[[:space:]][[:alnum:]]"))
      (unless (stringp set-regexp)
        (cl-case set-regexp
          ( 4 (setq alf-regexp (read-regexp "regexp: ")))
          (16 (setq alf-regexp default-regexp))
          ( t (unless alf-regexp
                (setq alf-regexp default-regexp) )))))
    (let ((beg (point))
          (re  (or (and (stringp set-regexp) set-regexp)
                    alf-regexp) ))
      (when (re-search-backward re (line-beginning-position) t)
        (while (looking-at "[[:space:]]")
          (forward-char) )
        (insert (make-string (- beg (point)) ?\s)) ))))

(declare-function align-from-left nil)

(provide 'align-from-left)


-- 
underground experts united
https://dataswamp.org/~incal




  reply	other threads:[~2024-02-02 15:53 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31 23:23 discoverability, better defaults and which-key in Emacs Jeremy Bryant
2024-02-01  2:45 ` Po Lu
2024-02-03 13:40   ` Philip Kaludercic
2024-02-04 22:03     ` Dmitry Gutov
2024-02-05  7:11       ` Philip Kaludercic
2024-02-05 15:38         ` Dmitry Gutov
2024-02-05 18:47           ` Philip Kaludercic
2024-02-05 19:17             ` Dmitry Gutov
2024-02-05 19:33               ` Justin Burkett
2024-02-05 23:05                 ` Dmitry Gutov
2024-02-06  2:49                   ` Justin Burkett
2024-02-06 23:12                     ` Dmitry Gutov
2024-02-07 12:35                       ` Eli Zaretskii
2024-02-07 18:31                         ` Dmitry Gutov
2024-02-07 19:13                           ` Eli Zaretskii
2024-02-07 19:51                             ` Dmitry Gutov
2024-02-08  1:46                           ` Visuwesh
2024-02-08  6:59                             ` Eli Zaretskii
2024-02-08 12:18                               ` Dmitry Gutov
2024-02-08 13:02                                 ` Eli Zaretskii
2024-02-08 13:36                                   ` Dmitry Gutov
2024-02-08 13:52                                     ` Eli Zaretskii
2024-02-08 14:43                                       ` Dmitry Gutov
2024-02-08 16:12                                         ` Dmitry Gutov
2024-02-11  2:17                                           ` Dmitry Gutov
2024-02-11  2:39                                             ` Po Lu
2024-02-11 12:30                                               ` Dmitry Gutov
2024-02-11  6:49                                             ` Eli Zaretskii
2024-02-11 12:26                                               ` Dmitry Gutov
2024-02-11 15:00                                                 ` Eli Zaretskii
2024-02-11 20:36                                                   ` Dmitry Gutov
2024-02-08 16:50                                         ` Eli Zaretskii
2024-02-08 13:41                                   ` Dmitry Gutov
2024-02-08 13:51                                   ` Rebinding Fn [Re: discoverability, better defaults and which-key in Emacs] Alan Mackenzie
2024-02-08 13:55                                     ` Eli Zaretskii
2024-02-08 14:04                                       ` Alan Mackenzie
2024-02-08 13:25                           ` discoverability, better defaults and which-key in Emacs Po Lu
2024-02-08 13:27                             ` Dmitry Gutov
2024-02-08 13:36                               ` Dmitry Gutov
2024-02-01  7:35 ` Eli Zaretskii
2024-02-01 21:16   ` Jeremy Bryant
2024-02-02  6:43     ` Eli Zaretskii
2024-02-02  7:00       ` Emanuel Berg
2024-02-02  7:43         ` Eli Zaretskii
2024-02-02 15:25           ` [External] : " Drew Adams
2024-02-02 15:53             ` Emanuel Berg [this message]
2024-02-02 16:04             ` Emanuel Berg
2024-02-03 11:46             ` Jeremy Bryant
2024-02-03 11:39           ` Jeremy Bryant
2024-02-03 12:12             ` Eli Zaretskii
2024-02-03 14:07               ` Jeremy Bryant
2024-02-03 15:15                 ` Eli Zaretskii
2024-02-04 22:18                   ` Jeremy Bryant
2024-02-05 12:41                     ` Eli Zaretskii
2024-02-03 11:30       ` Jeremy Bryant
2024-02-03 11:36       ` Moving which-key ELPA package into core - " Jeremy Bryant
2024-02-03 16:34         ` Stefan Monnier
2024-02-04 22:12           ` Jeremy Bryant
2024-02-04 23:06             ` Stefan Monnier
2024-02-01 21:17   ` orzodk
2024-02-01 22:24     ` Jeremy Bryant
2024-02-01 23:49       ` orzodk
2024-02-02  6:31     ` Eli Zaretskii
2024-02-02 16:00   ` Howard Melman
2024-02-02 19:24     ` Eli Zaretskii
2024-02-02 19:32       ` tomas
2024-02-02 20:16         ` Howard Melman
2024-02-03  7:25           ` Emanuel Berg
2024-02-03  8:49           ` Eli Zaretskii
2024-02-03 16:58             ` [External] : " Drew Adams
2024-02-04 22:25               ` Jeremy Bryant
2024-02-04 22:55                 ` Emanuel Berg
2024-02-05  3:40                   ` Emanuel Berg
2024-02-04 23:47                 ` Drew Adams
2024-02-05  1:46                   ` Emanuel Berg
2024-02-05  3:52               ` Divya Ranjan
2024-02-05 15:04                 ` Drew Adams
2024-02-04 18:34             ` Howard Melman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=871q9uamls.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).