all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: ram <chat@rj95.be>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: question regarding my emacs package
Date: Wed, 07 Jun 2023 15:53:08 +0000	[thread overview]
Message-ID: <873533mfq3.fsf@posteo.net> (raw)
In-Reply-To: <6cG8Tc55Zz8xk6rE6mJLfDxckAINPcYqp781yltsndzqq5146yw76EZ_2CoUtQT4P2j2afSx5VRD5G1-9qzFHWAW3LxYWwmxh87lvB2MgNE=@rj95.be> (ram's message of "Wed, 07 Jun 2023 03:18:07 +0000")

[-- Attachment #1: Type: text/plain, Size: 894 bytes --]

ram <chat@rj95.be> writes:

> hi, i am a professional programmer, but this is my first time
> submitting an emacs package. i have conversed a little with stefan
> monnier, and i believe the package i have meets the requirements for
> elpa submission, but i am unsure as to the appropriate licensure. i
> took some inspiration from two packages: dogears and gumshoe, neither
> of which is in elpa. however, i did not use any code from here; i just
> wanted some inspiration regarding the feature set

That should not be an issue, these packages appear to only be a source
of inspiration?

> it is unclear to me whether my package warrants inclusion in gnu or
> non gnu elpa, if at all, but i have certainly found it useful, despite
> its simplicity

Complexity is not a requirement for being useful :)

> here is the repo: https://github.com/gitrj95/breadcrumbs.el

Here are a few suggestions:


[-- Attachment #2: Type: text/plain, Size: 6620 bytes --]

diff -u /tmp/breadcrumbs.el.1 /tmp/breadcrumbs.el
--- /tmp/breadcrumbs.el.1	2023-06-07 17:32:50.162889593 +0200
+++ /tmp/breadcrumbs.el	2023-06-07 17:52:36.608268297 +0200
@@ -35,9 +35,9 @@
 ;; https://github.com/gitrj95/breadcrumbs.el
 ;;
 ;; In order to use breadcrumbs, `breadcrumbs-mode' must be enabled.
-;;
-;; Interface:
-;;
+
+;;; Interface:
+
 ;; `breadcrumbs-drop-breadcrumb' adds the current position in the
 ;; buffer to a ring.  If point is at a known breadcrumb, the existing
 ;; breadcrumb will be moved to the head of the ring.  Adding
@@ -59,9 +59,14 @@
 ;;; Code:
 
 (require 'ring)
-(require 'eieio)
+(require 'cl-lib)
 (require 'pulse)
 
+(defgroup breadcrumbs ()
+  "Track buffer positions."
+  :group 'convenience
+  :prefix "breadcrumbs-")
+
 (defvar breadcrumbs-ring nil
   "All dropped breadcrumbs, up to `breadcrumb-ring-max' breadcrumbs.")
 
@@ -81,44 +86,47 @@
 (defvar breadcrumbs-list-buffer nil
   "The \"*Breadcrumbs List*\" buffer.")
 
-(defclass breadcrumbs--breadcrumb ()
-  ((buffer-name
-    :initform (buffer-name)
-    :documentation "Name of the buffer.")
-   (buffer-position
-    :initform (point)
-    :documentation "Position in buffer."
-    )
-   (buffer-file-name
-    :initform (buffer-file-name)
-    :documentation "The full file path of this breadcrumb."))
-  "The breadcrumb definition.")
+(cl-defstruct breadcrumbs
+  "The breadcrumb definition."
+  (buffer-name
+   (buffer-name)
+   :documentation "Name of the buffer.")
+  (buffer-position
+   (point)
+   :documentation "Position in buffer.")
+  (buffer-file-name
+   (buffer-file-name)
+   :documentation "The full file path of this breadcrumb."))
 
 (defun breadcrumbs--setup ()
   "Set up the state required to start using breadcrumbs."
   (if (not breadcrumbs-ring)
       (setq breadcrumbs-ring (make-ring breadcrumb-ring-max)))
   (mapcar (lambda (fn)
-            (advice-add fn :around #'breadcrumbs--drop-around)) breadcrumbs-drop-around-fn-list))
+            (advice-add fn :around #'breadcrumbs--drop-around))
+	  breadcrumbs-drop-around-fn-list))
 
 (defun breadcrumbs--teardown ()
   "Tear down the state required for breadcrumbs."
   (setq breadcrumbs-ring nil)
   (setq breadcrumbs--neighbor nil)
   (mapcar (lambda (fn)
-            (advice-remove fn #'breadcrumbs--drop-around)) breadcrumbs-drop-around-fn-list))
+            (advice-remove fn #'breadcrumbs--drop-around))
+	  breadcrumbs-drop-around-fn-list))
 
 (defun breadcrumbs--jump (breadcrumb)
   "Jump to the specified breadcrumb."
   (setq breadcrumbs--neighbor breadcrumb)
-  (with-slots (buffer-name buffer-position buffer-file-name) breadcrumb
+  (let ((buffer-name (breadcrumbs-buffer-name breadcrumb))
+	(buffer-position (breadcrumbs-buffer-position breadcrumb))
+	(buffer-file-name (breadcrumbs-buffer-file-name breadcrumb)))
     (if (get-buffer buffer-name)
         (progn
           (switch-to-buffer buffer-name)
           (goto-char buffer-position))
       (find-file buffer-file-name)
       (goto-char buffer-position)
-      (setf buffer-name (buffer-name)))
+      (rename-buffer (buffer-name)))
     (pulse-momentary-highlight-one-line)))
 
 (defun breadcrumbs--drop ()
@@ -138,16 +146,18 @@
     (breadcrumbs--drop)
     result))
 
-(defun breadcrumbs--find-and-jump (&key direction)
+(defun breadcrumbs--find-and-jump (&rest args)
   "Find some candidate breadcrumb and jump to the next or previous, based on `direction'."
   (let ((jump-target
          (let ((candidate (make-instance 'breadcrumbs--breadcrumb)))
-           (if (ring-member breadcrumbs-ring candidate)
-               candidate))))
+           (and (ring-member breadcrumbs-ring candidate) candidate)))
+	(direction (plist-get args :type)))
     (cond (jump-target
            (breadcrumbs--jump
-            (cond ((eq direction 'next) (ring-next breadcrumbs-ring jump-target))
-                  ((eq direction 'previous) (ring-next breadcrumbs-ring jump-target)))))
+	    (ring-next
+	     (cond ((eq direction 'next) breadcrumbs-ring)
+                  ((eq direction 'previous) breadcrumbs-ring))
+	     jump-target)))
           (breadcrumbs--neighbor
            (if (eq direction 'previous)
                (breadcrumbs--jump breadcrumbs--neighbor))))))
@@ -156,14 +166,12 @@
 (define-minor-mode breadcrumbs-mode
   "Track positions in buffers and files using breadcrumbs."
   :global t
-  :init-value t
   (if breadcrumbs-mode
       (breadcrumbs--setup)
     (breadcrumbs--teardown)))
 
 (defvar breadcrumbs-list-mode-map
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map tabulated-list-mode-map)
     (define-key map (kbd "j") #'breadcrumbs-list-jump)
     (define-key map (kbd "<RET>") #'breadcrumbs-list-jump)
     (define-key map (kbd "k") #'breadcrumbs-list-delete)
@@ -172,13 +180,14 @@
 
 (defun breadcrumbs--format-slot (slot len)
   "Formats a breadcrumbs slot."
-  (let ((format-string (format "%%-%ss" len)))
-    (format format-string
-            (if slot slot ""))))
+  (let ((format-string (format "%%-%ds" len)))
+    (format format-string (or slot ""))))
 
 (defun breadcrumbs--format-breadcrumb (breadcrumb)
   "Return a formatted breadcrumb as a vector of formatted slots."
-  (with-slots (buffer-name buffer-position buffer-file-name) breadcrumb
+  (let ((buffer-name (breadcrumbs-buffer-name breadcrumb))
+	(buffer-position (breadcrumbs-buffer-position breadcrumb))
+	(buffer-file-name (breadcrumbs-buffer-file-name breadcrumb)))
     (vector
      (breadcrumbs--format-slot buffer-name 16)
      (breadcrumbs--format-slot buffer-position 16)
@@ -199,13 +208,10 @@
 
 (define-derived-mode breadcrumbs-list-mode tabulated-list-mode
   "Tabular list mode displaying tracked breadcrumbs."
-  (setq-local tabulated-list-format
+  (setq-local tabulated-list-entries #'breadcrumbs-list--entries
+	      tabulated-list-format
               `[("Buffer" 16) ("Position" 16) ("File" 32)])
-  (add-hook 'tabulated-list-revert-hook
-            (lambda ()
-              (setf tabulated-list-entries (breadcrumbs-list--entries))))
-  (tabulated-list-init-header)
-  (breadcrumbs-list--revert))
+  (tabulated-list-init-header))
 
 (defun breadcrumbs-list-jump ()
   "Jump to breadcrumb from \"*Breadcrumbs List*\"."
@@ -217,8 +223,8 @@
   (interactive)
   (ring-remove breadcrumbs-ring
                (ring-member breadcrumbs-ring (tabulated-list-get-id)))
-  (if (ring-empty-p breadcrumbs-ring)
-      (setq breadcrumbs--neighbor nil))
+  (when (ring-empty-p breadcrumbs-ring)
+    (setq breadcrumbs--neighbor nil))
   (breadcrumbs-list--revert))
 
 ;;;###autoload

Diff finished.  Wed Jun  7 17:52:43 2023

  reply	other threads:[~2023-06-07 15:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07  3:18 question regarding my emacs package ram
2023-06-07 15:53 ` Philip Kaludercic [this message]
2023-06-07 18:04   ` Philip Kaludercic
2023-06-07 19:45     ` ram
2023-06-07 19:48       ` Philip Kaludercic
2023-06-07 19:50         ` ram
2023-06-07 22:34           ` ram
2023-06-08  7:13             ` ram
2023-06-08  7:26               ` Philip Kaludercic
2023-06-08 18:50                 ` ram
2023-09-08  7:40                   ` Philip Kaludercic
2023-06-11 11:41                 ` Madhu
2023-06-12 12:52                   ` Madhu
2023-06-12 16:40                     ` Andrea Corallo
2023-06-13  4:01                       ` Madhu
2023-06-13  8:55                         ` Andrea Corallo
2023-06-13  9:19                           ` Madhu
2023-06-13 23:55                             ` Michael Heerdegen
2023-06-14 16:10                               ` Mattias Engdegård
2023-06-16  3:53                                 ` Michael Heerdegen
2023-06-16  4:46                                   ` Madhu
2023-06-16 15:28                   ` Michael Heerdegen
2023-06-17  3:01                     ` ram via Emacs development discussions.
2023-06-18  0:40                       ` Michael Heerdegen
2023-06-29 19:28                       ` ram
2023-06-11 18:49 ` João Távora
2023-06-11 19:08   ` ram via Emacs development discussions.
2023-06-12  8:45     ` Philip Kaludercic
2023-06-12 10:23       ` João Távora
2023-06-12 10:54         ` Philip Kaludercic
2023-06-12 20:43           ` João Távora
2023-06-13  0:36             ` ram via Emacs development discussions.
2023-06-13 18:13               ` João Távora
2023-06-13 21:46                 ` ram

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=873533mfq3.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=chat@rj95.be \
    --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 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.