From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: find-file-dwim.el Date: Tue, 23 Jul 2024 06:41:05 +0000 Message-ID: <87sew0k3um.fsf@posteo.net> References: <87o76qs8el.fsf@dataswamp.org> <87le1urtgp.fsf@dataswamp.org> <878qxtle3a.fsf@posteo.net> <87o76pq6hb.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39552"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Emanuel Berg Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 23 10:52:40 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 1sWBGB-000A9n-Od for ged-emacs-devel@m.gmane-mx.org; Tue, 23 Jul 2024 10:52:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWBFU-00060o-DZ; Tue, 23 Jul 2024 04:51:56 -0400 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 1sWBFR-0005op-8B for emacs-devel@gnu.org; Tue, 23 Jul 2024 04:51:54 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWBFN-0006Oy-GX for emacs-devel@gnu.org; Tue, 23 Jul 2024 04:51:52 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id EB791240027 for ; Tue, 23 Jul 2024 10:51:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1721724706; bh=NxbGqkvVzcUGQS/DtpQl1XyW4DEd2lqCcAycH6qRzlw=; h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=WsPmBF2UGwq50yB22is7tieeQLHmq6Qp62Bl+A2MHPSZF3Js7Ckqp4p91hU9olkVx 2A+JuQUwqv++P8fF3DY+BG/IkKzDs7swLCKQ2QeNsxhndt++wpUFcbwJJK24aDKdsF JOaDFyLGWUlDszSZ4CIYXLUsF3BE1wLmBY1HQqp2aULxv/cS/CfoW2fgtf9s06Atg9 K6nWvk5NpnF5gUtoPV5Z7PT0FeURKpY/KZO29lDzRbFGQSxhC7m1u/SmAeh5DOV+BJ Nyr3rxJf+boiJFfWvRYedm5GhrFyOl5dCezkMSo+kep1T8GRMQHGlYen0m+WKVa22a ulojnx3t0ocBA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4WSrVT2djJz9rxR for ; Tue, 23 Jul 2024 10:51:45 +0200 (CEST) Resent-To: emacs-devel@gnu.org Resent-From: Philip Kaludercic Resent-Date: Tue, 23 Jul 2024 10:51:44 +0200 Resent-Message-ID: <87le1sjxsv.fsf@posteo.net> In-Reply-To: <87o76pq6hb.fsf@dataswamp.org> (Emanuel Berg's message of "Tue, 23 Jul 2024 02:47:44 +0200") OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:321976 Archived-At: --=-=-= Content-Type: text/plain Content-Disposition: inline Emanuel Berg writes: > The following message is a courtesy copy of an article > that has been posted to gmane.emacs.devel as well. > > Philip Kaludercic wrote: > >> It might just be, but your message confuses me: I am not ^ *me >> sure what you are trying to say here, are you proposing >> adding the these functions to the core (in which case >> a patch would be more appropriate) or to ELPA (in which case >> we'd like a link to some Git repository). If you are just >> interested in sharing code with others, perhaps the >> development mailing list is not the right place to do so. >> (Also, please don't forget to CC me in your response, >> I recall this being an issue in the past where I didn't see >> your response until much later). > > Suggestion: The next time you or anyone else gets confused by > my actions, instead of theorizing several different scenarios > and criticizing each one in turn on a public ML, either send > me a private mail where you just ask - or, even better, accept > that you cannot understand every other human being on the > planet - instead, focus on whatever it is _you_ are doing, > I think will be a lot less confusing simple as it may sound. My apologies if I offended you, it certainly wasn't my intention. My "job" is just to review ELPA submissions, and I wanted to check if your message was a proposal to add a package or not. > What I am doing? I am doing an alternative to `find-file', > called `find-file-dwim'. That is clear, my question was with what intention are you posting your code on the development mailing list: (a) To add the code to ELPA, (b) To add the code to the Emacs core, (c) None of the above. Depending on which of these > As of now, some building blocks are in place, you can check > out version 0.3.2 here - but it needs much more time and > possibly some additional big things to be added, as well. > > https://dataswamp.org/~incal/emacs-init/find-file-dwim.el Here are a few comments and improvements, fwiw: --=-=-= Content-Type: text/plain Content-Disposition: inline diff -u /tmp/find-file-dwim-comments.el /tmp/find-file-dwim.el --- /tmp/find-file-dwim-comments.el 2024-07-23 08:33:36.412846100 +0200 +++ /tmp/find-file-dwim.el 2024-07-23 04:59:05.000000000 +0200 @@ -1,112 +1,72 @@ -;;; find-file-dwim.el --- A `find-file' alternative -*- lexical-binding: t; -*- - -;; Copyright (C) 2024 Philip Kaludercic - -;; Author: Emanuel Berg -;; Keywords: files -;; URL: https://dataswamp.org/~incal/emacs-init/find-file-dwim.el -;; Created: 2024-07-22 -;; Version: 0.3.1 - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; This package provides an alternative to `find-file'. (Perhaps -;; explain the difference betweeen `find-file-dwim' and -;; `find-file-at-point' or the future history of `find-file'). - -;;; Code: +;;; -*- lexical-binding: t -*- +;; +;; this file: +;; https://dataswamp.org/~incal/emacs-init/find-file-dwim.el +;; +;; created: 2024-07-22 +;; version: 0.3.1 (require 'cl-lib) (require 'psea) ; https://dataswamp.org/~incal/emacs-init/psea.el -(defvar ffd-coll (sort-mod-time-sec) - "***DOCUMENTATION MISSING HERE***") +(defvar ffd-coll) +(setq ffd-coll (sort-mod-time-sec)) -;;;###autoload (defun find-file-dwim (&optional f) - "***DOCUMENTATION MISSING HERE***" (interactive (list - ;; are you sure you want to evaluate `ffd-coll' at - ;; load time? `sort-mod-time-sec' takes an implicit - ;; argument (the current directory) that this function - ;; will operate on the same directory, no matter where - ;; it is invoked. I don't think that qualifies at - ;; DWIM... - (completing-read-default "File: " ffd-coll nil nil default-directory))) + (completing-read-default "File: " ffd-coll nil nil default-directory) )) (when (file-exists-p f) - (find-file f))) + (find-file f) )) -;; (defalias 'f #'find-file-dwim) please don't do this by default! +(defalias 'f #'find-file-dwim) -(defun buffers () ;this appears to be dead code - "***DOCUMENTATION MISSING HERE***" - (mapcar #'buffer-name (buffer-list))) +(defun buffers () + (mapcar #'buffer-name (buffer-list)) ) ;; (buffers) -(defun get-dirs (fs) ;this as well - "***DOCUMENTATION MISSING HERE***" +(defun get-dirs (fs) (let ((dirs (cl-remove-if-not #'file-directory-p fs))) - (cl-sort dirs #'string<))) ;`directory-files' sorts by default! + (cl-sort dirs #'string<) )) ;; (get-dirs (directory-files "." t)) -(defun remove-data (ds) ;please prefix functions for their namespace - "***DOCUMENTATION MISSING HERE***" - (mapcar #'cadr ds)) +(defun remove-data (ds) + (mapcar #'cadr ds) ) (defun mod-time-sec (f) - "***DOCUMENTATION MISSING HERE***" - (let* ((attribs (file-attribute-modification-time (file-attributes f))) - (s (time-convert attribs 'integer))) - (list s f))) + (let*((attribs (file-attribute-modification-time (file-attributes f))) + (s (time-convert attribs 'integer) )) + (list s f) )) ;; (mod-time-sec "~/.emacs") (defun sort-mod-time-sec (&optional dir) - "***DOCUMENTATION MISSING HERE***" - (unless dir - (setq dir default-directory)) - (let* ((fs (directory-files dir t nil t)) - (all (mapcar #'mod-time-sec fs))) - (cl-sort all #'> :key #'car))) + (or dir (setq dir default-directory)) + (let*((fs (directory-files dir t nil t)) + (all (mapcar #'mod-time-sec fs) )) + (cl-sort all #'> :key #'car) )) ;; (sort-mod-time-sec) -(defun psea-hit (s fs &optional gov) ;this is dead code and uses the prefix of your other library? - "***DOCUMENTATION MISSING HERE***" +(defun psea-hit (s fs &optional gov) (or gov (setq gov 70)) (cl-loop - with perc - with res - for f in fs do - (setq perc (sdp s f)) ;`cl-loop' has keywords for these operations! - (when (< gov perc) - (cl-pushnew (list perc f) res)) - finally return (remove-data (cl-sort res #'> :key #'car)))) + with perc + with res + for f in fs do + (setq perc (sdp s f)) + (when (< gov perc) + (cl-pushnew (list perc f) res) ) + finally return (remove-data (cl-sort res #'> :key #'car)) )) ;; (psea-hit "buffer-menu" (buffers)) ;; (psea-hit "find-file-dwim.el" (remove-data (sort-mod-time-sec))) -(defun re-hit (re fs) ;nobody calls this, is this part of the library interface? - "***DOCUMENTATION MISSING HERE***" - (cl-remove-if-not (lambda (f) (string-match re f)) fs)) +(defun re-hit (re fs) + (cl-remove-if-not (lambda (f) (string-match re f)) fs) ) ;; (re-hit "line" (buffers)) ;; (re-hit "line" (remove-data (sort-mod-time-sec))) (provide 'find-file-dwim) -;;; find-file-dwim.el ends here Diff finished. Tue Jul 23 08:33:58 2024 --=-=-= Content-Type: text/plain Content-Disposition: inline -- Philip Kaludercic on peregrine --=-=-=--