首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用带有Emacs的`gist.el`编辑Gist文件名

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

Stack Overflow用户
提问于 2014-04-11 05:22:07
回答 1查看 202关注 0票数 1

关于如何使用gist.el编辑现有Gist的文件名,任何人都可以引导我朝正确的方向前进吗?我尝试过修改gist-edit-current-description来处理文件名的修改,但是我尝试的变体没有起作用。下面是gist-edit-current-description函数--我假设编辑文件名与描述类似:

代码语言:javascript
复制
(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先前的回答):

代码语言:javascript
复制
(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)))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-25 18:53:30

开发人员在2014年12月29日添加了这个功能--函数是gist-mode-write-file,在访问文件时使用它。第55期:https://github.com/defunkt/gist.el/issues/55

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23004113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档