From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.devel Subject: Re: [External] : Re: discoverability, better defaults and which-key in Emacs Date: Fri, 02 Feb 2024 16:53:51 +0100 Message-ID: <871q9uamls.fsf@dataswamp.org> References: <874jetaxri.fsf@jeremybryant.net> <86fryc1vsh.fsf@gnu.org> <87y1c398u8.fsf@jeremybryant.net> <867cjnz7rc.fsf@gnu.org> <87jznnbbax.fsf@dataswamp.org> <86v877xqez.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8720"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:jFgiFmiI9U8GIizbVpy/NYMxwAg= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 02 16:58:14 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rVvvi-00025g-00 for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Feb 2024 16:58:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvvK-0004pE-Fr; Fri, 02 Feb 2024 10:57:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVvrn-00020f-4l for emacs-devel@gnu.org; Fri, 02 Feb 2024 10:54:11 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVvrl-0008Oy-5A for emacs-devel@gnu.org; Fri, 02 Feb 2024 10:54:10 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1rVvrh-0006Ez-Fv for emacs-devel@gnu.org; Fri, 02 Feb 2024 16:54:05 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 02 Feb 2024 10:57:48 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:315761 Archived-At: 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