Skip to content

Commit 3e68c64

Browse files
committed
Add option for ask for file name
* Add defcustom gist-ask-for-filename * Add function gist-ask-for-filename-maybe * Modify function gist-region
1 parent 9a5c382 commit 3e68c64

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

gist.el

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
;; Michael Ivey
88
;; Phil Hagelberg
99
;; Dan McKinley
10-
;; Version: 1.3.1
10+
;; Marcelo Muñoz Araya <[email protected]>
11+
;; Version: 1.3.2
1112
;; Package-Requires: ((emacs "24.1") (gh "0.9.2"))
1213
;; Keywords: tools
1314
;; Homepage: https://github.com/defunkt/gist.el
@@ -92,6 +93,11 @@
9293
:type 'boolean
9394
:group 'gist)
9495

96+
(defcustom gist-ask-for-filename nil
97+
"If non-nil, prompt for change default file name before submitting gist."
98+
:type 'boolean
99+
:group 'gist)
100+
95101
(defcustom gist-created-fmt "Paste created: %s"
96102
"Format for the message that gets shown upon successful gist
97103
creation. Must contain a single %s for the location of the newly
@@ -182,6 +188,11 @@ appropriate modes from fetched gist files (based on filenames)."
182188
(when gist-ask-for-description
183189
(read-from-minibuffer "Gist description: ")))
184190

191+
(defun gist-ask-for-filename-maybe (fname)
192+
(if gist-ask-for-filename
193+
(read-string (format "File name (%s): " fname) nil nil fname)
194+
fname))
195+
185196
;;;###autoload
186197
(defun gist-region (begin end &optional private callback)
187198
"Post the current region as a new paste at gist.github.com
@@ -194,7 +205,8 @@ With a prefix argument, makes a private paste."
194205
(ext (or (cdr (assoc major-mode gist-supported-modes-alist))
195206
(file-name-extension file)
196207
"txt"))
197-
(fname (concat (file-name-sans-extension name) "." ext))
208+
(proposal-fname (concat (file-name-sans-extension name) "." ext))
209+
(fname (gist-ask-for-filename-maybe proposal-fname))
198210
(files (list
199211
(make-instance 'gh-gist-gist-file
200212
:filename fname

0 commit comments

Comments
 (0)