git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [StGit PATCH 2/2] Emacs mode: delete patches

From
David Kågedal <davidk@lysator.liu.se>
Date
Feb 11, 2008, 09:42 UTC
Message-ID
<87wspbsubl.fsf@lysator.liu.se>
In-Reply-To
<20080210204851.17886.69638.stgit@yoghurt>
Karl Hasselström <kha@treskal.com> writes:
Show 10 quoted lines
> Teach the emacs mode to delete patches.
>
> Signed-off-by: Karl Hasselström <kha@treskal.com>
>
> ---
>
> David, could you have a look at this as well? In addition to me being
> elisp challenged, there are the following issues:
>
>   * Is "d" a reasonable binding? Any better suggestion?

We could reserve "d" for moving a patch "down", maybe. The more destructive commands could be on less accessible keys. Maybe "D" or "C-d".

>   * Currently, this command requires you to mark one or more patches
>     before deleting. This is convenient when deleting more than one
>     patch, but one could argue that it should be possible to delete
>     the patch at point without having to select it.
You need something like this:
--- a/contrib/stgit.el
+++ b/contrib/stgit.el
@@ -187,6 +187,15 @@ Commands:
         (match-string-no-properties 1)
       nil)))
 
+(defun stgit-selected-patches ()
+  "Return the names of the marked patches, or the patch on the current line."
+  (if stgit-marked-patches
+      (stgit-marked-patches)
+    (let ((patch (stgit-patch-at-point)))
+      (if patch
+          (list patch)
+        '()))))
+
 (defun stgit-goto-patch (patch)
   "Move point to the line containing PATCH"
   (let ((p (point)))

>   * We should probably ask for confirmation before deleting.

Absolutely. Something like this (untested):

(defun stgit-delete (patch-names)
  "Delete the named patches"
  (interactive (list (stgit-selected-patches)))
  (if (zerop (length patch-names))
      (error "No patches to delete")
    (when (yes-or-no-p (format "Really delete %d patches? "
                               (length patch-names)))
      (stgit-capture-output nil
        (apply 'stgit-run "delete" patch-names))
      (stgit-refresh))
-- 
David Kågedal
Previous: Karl HasselströmNext: Karl Hasselström
Message 16 of 21 in “StGit: kha/safe and kha/experimental updated”
  1. Karl HasselströmFeb 10, 2008
  2. 0/5 Convert "stg new" to the new infrastructureKarl Hasselström, Feb 10, 2008
  3. 1/5 Disable patchlog test for "stg new"Karl Hasselström, Feb 10, 2008
  4. 2/5 Convert "stg new" to the new infrastructureKarl Hasselström, Feb 10, 2008
  5. 3/5 Refactor --author/--committer optionsKarl Hasselström, Feb 10, 2008
  6. Subject: [PATCH] fix stg edit commandPeter Oberndorfer, Feb 12, 2008
  7. Karl HasselströmFeb 12, 2008
  8. Refactor --author/--committer optionsKarl Hasselström, Feb 12, 2008
  9. 4/5 Let "stg new" support more message optionsKarl Hasselström, Feb 10, 2008
  10. 5/5 Emacs mode: use "stg new --file"Karl Hasselström, Feb 10, 2008
  11. David KågedalFeb 11, 2008
  12. Karl HasselströmFeb 11, 2008
  13. 0/2 Convert "stg delete" to the new infrastructureKarl Hasselström, Feb 10, 2008
  14. 1/2 Convert "stg delete" to the new infrastructureKarl Hasselström, Feb 10, 2008
  15. 2/2 Emacs mode: delete patchesKarl Hasselström, Feb 10, 2008
  16. David KågedalFeb 11, 2008
  17. Karl HasselströmFeb 11, 2008
  18. David KågedalFeb 11, 2008
  19. 1/2 Emacs mode: change "stg repair" bindingKarl Hasselström, Feb 11, 2008
  20. 2/2 Emacs mode: delete patchesKarl Hasselström, Feb 11, 2008
  21. Catalin MarinasFeb 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.