如何使用带有Emacs的`gist.el`编辑Gist文件名

时间:2014-04-11 05:22:07

标签: emacs elisp

任何人都可以引导我指导如何使用gist.el编辑现有要点的文件名。我已经尝试修改gist-edit-current-description来处理文件名修改,但我尝试过的变体无法正常工作。这是gist-edit-current-description函数 - 我假设编辑文件名将类似于描述:

  
(defun gist-edit-current-description ()
  (interactive)
  (let* ((id (tabulated-list-get-id))
         (gist (gist-list-db-get-gist id))
         (old-descr (oref gist :description))
         (new-descr (read-from-minibuffer "Description: " old-descr)))
    (let* ((g (clone gist
                     :files nil
                     :description new-descr))
           (api (gist-get-api t))
           (resp (gh-gist-edit api g)))
      (gh-url-add-response-callback resp
                                    (lambda (gist)
                                      (gist-list-reload))))))

这可能有助于给某人一些想法 - 这是一种在创建Gist时设置文件名的方法(它基于@Jordon Biondo的先前答案 - https://stackoverflow.com/a/22973794/2112489):

  
(defun gist-region-with-filename-description (begin end &optional filename description private callback)
  "Post the current region as a new paste at gist.github.com
Copies the URL into the kill ring.
With a prefix argument, makes a private paste."
  (interactive "r\nsGist Description: \nP") ;; we handle the prompt here!
  (let* ((file (or (buffer-file-name) (buffer-name)))
         (name (file-name-nondirectory file))
         (ext (or (cdr (assoc major-mode gist-supported-modes-alist))
                  (file-name-extension file)
                  "txt"))
         (fname (if filename filename (concat (file-name-sans-extension name) "." ext)))
         (files (list
                 (gh-gist-gist-file "file"
                                    :filename fname
                                    :content (buffer-substring begin end)))))
    ;; finally we use our new arg to specify the description in the internal call
    (gist-internal-new files private description callback)))

(defun gist-buffer-with-filename-description (&optional filename description private)
  "Post the current buffer as a new paste at gist.github.com.
Copies the URL into the kill ring.
With a prefix argument, makes a private paste."
  (interactive "P")
  (let* (
      (filename (if filename filename (read-string "Filename:  " (buffer-name))))
      (description (if description description (read-string "Description:  " (buffer-name)))))
    (gist-region-with-filename-description (point-min) (point-max) filename description private nil)))

1 个答案:

答案 0 :(得分:0)

开发人员于2014年12月29日添加了此功能 - 功能为gist-mode-write-file,在访问文件时使用。问题编号55:https://github.com/defunkt/gist.el/issues/55