~yoctocell/git-email-devel

Remove needless let form for project detection v1 PROPOSED

Protesilaos Stavrou: 6
 Remove needless let form for project detection
 Remove needless gensym
 Add or reword doc strings to placate the compiler
 Fix project.el project string for Emacs 29
 Do not pollute the kill-ring for email composition
 Add minibuffer histories to all relevant prompts

 6 files changed, 47 insertions(+), 26 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~yoctocell/git-email-devel/patches/31106/mbox | git am -3
Learn more about email & git

[PATCH 1/6] Remove needless let form for project detection Export this patch

---
 git-email.el | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/git-email.el b/git-email.el
index 27b6238..75f45c2 100644
--- a/git-email.el
+++ b/git-email.el
@@ -249,13 +249,12 @@ (declare-function projectile-project-root "projectile")
(defun git-email--get-current-project ()
  "Return the path of the current project.
Falls back to `default-directory'."
  (let ((dir (or (and (bound-and-true-p projectile-known-projects)
                      (projectile-project-root))
                 (and (bound-and-true-p project-list-file)
                      (cdr (project-current)))
                 (vc-root-dir)
                 default-directory)))
    dir))
  (or (and (bound-and-true-p projectile-known-projects)
           (projectile-project-root))
      (and (bound-and-true-p project-list-file)
           (cdr (project-current)))
      (vc-root-dir)
      default-directory))



;;;; Get contents from patch
-- 
2.35.2



-- 
Protesilaos Stavrou
https://protesilaos.com

[PATCH 2/6] Remove needless gensym Export this patch

---
 git-email.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-email.el b/git-email.el
index 75f45c2..7e4febd 100644
--- a/git-email.el
+++ b/git-email.el
@@ -327,7 +327,7 @@ (defun git-email--fontify-diff (text)
(defun git-email--fontify-using-faces (text)
  "Fontify TEXT using faces."
  (let ((pos 0)
        (next (gensym)))
        next)
    (while (setq next (next-single-property-change pos 'face text))
      (put-text-property pos next 'font-lock-face
                         (get-text-property pos 'face text) text)
-- 
2.35.2



-- 
Protesilaos Stavrou
https://protesilaos.com

[PATCH 3/6] Add or reword doc strings to placate the compiler Export this patch

---
 git-email.el | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/git-email.el b/git-email.el
index 7e4febd..a1dff79 100644
--- a/git-email.el
+++ b/git-email.el
@@ -177,9 +177,8 @@ (defcustom git-email-generate-message-buffer

(defcustom git-email-buffer-p-function
  #'git-email-buffer-p
  "Function used for determining if a buffer contains an unsent
patch based on the buffer name.  The function must take one
argument --- the buffer name."
  "Function to test if buffer has an unsent patch.
The function must take one argument: the buffer's name."
  :type 'function
  :group 'git-email
  :package-version '(git-email . "0.3.0"))
@@ -283,10 +282,10 @@ (defvar git-email-subject-regexp
          eol)))

(defun git-email--extract-subject ()
  "Extract the subject from the current buffer.  git-format-patch
will add a newline in the subject if the subject is too long.
Just using `git-email--extract-header' would result in part of
the subject being cut of.  See what I did there?  ;-)"
  "Extract the subject from the current buffer.
git-format-patch will add a newline in the subject if the subject
is too long.  Just using `git-email--extract-header' would result
in part of the subject being cut of.  See what I did there?  ;-)"
  (let ((string (buffer-substring-no-properties (point-min) (point-max))))
    (string-match git-email-subject-regexp string)
    (string-remove-prefix
@@ -467,15 +466,16 @@ (defun git-email-format-patch (args range keep)
;;;; Misc

(defun git-email-generate-message-buffer-name (_type address _group)
  "Generate a buffer name that looks like this:
  "Generate a buffer name in the form of:

\"* git-email unsent patch to *** TO ADDRESS HERE *** *\""
  (generate-new-buffer-name
   (concat "*git-email unsent patch to " address " *" )))

(defun git-email-buffer-p (name)
  "Check whether a buffer is contains an unsent patch based on its
NAME."
  "Test if NAME buffer has an unsent patch.
The heuristic is to check if the buffer's name includes the
string 'git-email-unsent-patch'."
  (if (string-match "git-email-unsent-patch" name)
      t
    nil))
@@ -484,7 +484,7 @@ (defun git-email-buffer-p (name)
;;;; Operate on emails

(defun git-email-message-buffer-greaterp (old new)
  "Compare the number in the buffer name of OLD with NEW"
  "Compare the number in the buffer name of OLD with NEW."
  (cl-flet ((regexp (name)
                    (string-to-number
                     (replace-regexp-in-string ".*<\\([0-9]+\\)>"
@@ -508,6 +508,9 @@ (defun git-email-send-all ()
          sorted-buffers)))

(defun git-email--rewrite-header-in-buffer (buffer header value append)
  "Rewrite BUFFER's HEADER with VALUE.
If APPEND is non-nil, append the VALUE to the existing one
instead of overwriting it."
  (switch-to-buffer buffer)
  (save-excursion
    (goto-char (point-min))
@@ -523,6 +526,7 @@ (defun git-email--rewrite-header-in-buffer (buffer header value append)
          (insert "\n" (concat (capitalize header) ": " value)))))))

(defun git-email--send-files (files)
  "Send email for each file in FILES."
  (dolist (file files)
    (run-hooks 'git-email-pre-compose-email-hook)
    (let ((message-generate-new-buffers
@@ -532,8 +536,8 @@ (defun git-email--send-files (files)

;;;###autoload
(defun git-email-rewrite-header (header value &optional append)
  "Re-write the value of HEADER to VALUE, if HEADER doesn't exist
yet, just set it to VALUE.
  "Re-write value of HEADER to VALUE.
If HEADER doesn't exist yet, just set it to VALUE.

With prefix argument APPEND, append the VALUE to HEADER instead
of overwriting it.
-- 
2.35.2



-- 
Protesilaos Stavrou
https://protesilaos.com

[PATCH 4/6] Fix project.el project string for Emacs 29 Export this patch

---
 git-email.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/git-email.el b/git-email.el
index a1dff79..3a4159e 100644
--- a/git-email.el
+++ b/git-email.el
@@ -245,13 +245,19 @@ (defun git-email--get-files ()

(declare-function projectile-project-root "projectile")

(defun git-email--project-current ()
  "Return directory from `project-current' based on Emacs version."
  (if (>= emacs-major-version 29)
      (car (last (project-current)))
    (cdr (project-current))))

(defun git-email--get-current-project ()
  "Return the path of the current project.
Falls back to `default-directory'."
  (or (and (bound-and-true-p projectile-known-projects)
           (projectile-project-root))
      (and (bound-and-true-p project-list-file)
           (cdr (project-current)))
           (git-email--project-current))
      (vc-root-dir)
      default-directory))

-- 
2.35.2



-- 
Protesilaos Stavrou
https://protesilaos.com

[PATCH 5/6] Do not pollute the kill-ring for email composition Export this patch

---
 git-email.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-email.el b/git-email.el
index 3a4159e..a5be846 100644
--- a/git-email.el
+++ b/git-email.el
@@ -395,7 +395,7 @@ (defun git-email--compose-email (patch-file)
    ;; Jump to subject or 'to' address if they are emtpy
    (when (or (re-search-backward "\\*\\*\\* TO ADDRESS HERE \\*\\*\\*" nil t)
              (re-search-backward "\\*\\*\\* SUBJECT HERE \\*\\*\\*" nil t))
      (kill-line))))
      (delete-region (point) (point-at-eol)))))



;;;; Format patches
-- 
2.35.2



-- 
Protesilaos Stavrou
https://protesilaos.com

[PATCH 6/6] Add minibuffer histories to all relevant prompts Export this patch

---
 git-email.el | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/git-email.el b/git-email.el
index a5be846..231e772 100644
--- a/git-email.el
+++ b/git-email.el
@@ -400,6 +400,9 @@ (defun git-email--compose-email (patch-file)


;;;; Format patches

(defvar git-email--revision-history '()
  "Minibuffer history of `git-email--minibuffer-get-revision'.")

(defun git-email--minibuffer-get-revision ()
  "Let the user choose a git revision from the minibuffer."
  (interactive)
@@ -421,7 +424,8 @@ (defun git-email--minibuffer-get-revision ()
                           (cycle-sort-function . identity))
              (complete-with-action
               action revs string pred)))))
    (git-email--parse-revision (completing-read "Revision: " sorted-revs))))
    (git-email--parse-revision (completing-read "Revision: " sorted-revs
                                                nil nil nil 'git-email--revision-history))))

(defun git-email--parse-revision (rev)
  "Return only the revision hash from REV.
@@ -434,6 +438,9 @@ (defun git-email--log-get-revision ()
  (when (eq major-mode 'vc-git-log-view-mode)
    (cadr (log-view-current-entry (point) t))))

(defvar git-email--format-patch-args-history '()
  "Minibuffer history of `git-email-format-patch' ARGS.")

;;;###autoload
(defun git-email-format-patch (args range keep)
  "Format and send patch(es) using 'git format-patch'.
@@ -451,7 +458,8 @@ (defun git-email-format-patch (args range keep)
                          (lambda (a) (concat a " "))
                          (completing-read-multiple
                           "Args: " git-email-format-patch-extra-args
                           nil nil git-email-format-patch-default-args)))
                           nil nil git-email-format-patch-default-args
                           'git-email--format-patch-args-history)))
         (or (run-hook-with-args-until-success
              'git-email-get-revision-functions)
             (git-email--minibuffer-get-revision))
@@ -540,6 +548,9 @@ (defun git-email--send-files (files)
      (git-email--compose-email file))
    (run-hooks 'git-email-post-compose-email-hook)))

(defvar git-email--rewrite-header-history '()
  "Minibuffer history of `git-email-rewrite-header'.")

;;;###autoload
(defun git-email-rewrite-header (header value &optional append)
  "Re-write value of HEADER to VALUE.
@@ -553,7 +564,8 @@ (defun git-email-rewrite-header (header value &optional append)
give you an address to send your patches to."
  (interactive
   (list (completing-read "Header to re-write: "
                          git-email-headers)
                          git-email-headers
                          nil nil nil 'git-email--rewrite-header-history)
         (read-from-minibuffer "Set header to: ")
         current-prefix-arg))
  (let ((buffers (message-buffers))
-- 
2.35.2



-- 
Protesilaos Stavrou
https://protesilaos.com