Giter VIP home page Giter VIP logo

igist's Introduction

https://melpa.org/packages/igist-badge.svg https://stable.melpa.org/packages/igist-badge.svg https://img.shields.io/badge/license-GPL-brightgreen.svg

About

igist is a modern package that aims to help you never leave Emacs to manage your GitHub gists.

./igist-table-demo.gif

./igist-demo.gif

igist

Requirements

Installation

MELPA

igist is available on MELPA.

To get started, enable installing packages from MELPA:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

To fetch the list of packages you can do:

<M-x> package-refresh-contents

And after that igist can be installed with:

<M-x> package-install igist

Manually

Download the repository and it to your load path in your init file:

(add-to-list 'load-path "/path/to/igist")
(require 'igist)

With use-package

(use-package igist
  :bind (("M-o" . igist-dispatch)))

Or if you use straight.el:

(use-package igist
  :bind (("M-o" . igist-dispatch))
  :straight (igist
             :repo "KarimAziev/igist"
             :type git
             :host github))

Auth

igist manages authentication through two customizable variables:

  • igist-current-user-name: This variable should be set to a string containing your GitHub username.
  • igist-auth-marker: This variable can either be a string containing the OAuth token or a symbol indicating where to fetch the OAuth token.

Setting Up token

Firsly, you need to ensure that you have a GitHub API token with scope gist:

  1. Log in to your GitHub account and navigate to settings.
  2. Select the Developer settings option on the bottom of the sidebar.
  3. Here you’ll see a Personal access tokens section, click on it.
  4. Click on “Generate new token”, give your token a descriptive name.
  5. Ensure the “gist” scope is checked, this will give igist the necessary permissions it needs to manage your gists.
  6. Click on Generate token at the bottom of the page. Be sure to copy your new personal access token now as you cannot see it again.

After getting your token, you can supply it to igist in one of two ways.

Secure Way: Using auth-sources

Emacs auth-sources provide a secure way to store your GitHub username and OAuth token.

To employ this method, set igist-auth-marker to the symbol igist:

(setq igist-auth-marker 'igist)

Next, add an entry to your auth-sources:

machine api.github.com login YOUR-GITHUB-USERNAME^igist password YOUR-GITHUB-TOKEN

You can add this entry to your ~/.authinfo.gpg file (recommended for secure, encrypted storage) or ~/.authinfo (see variable auth-sources).

You can read more in ghub manual, as igist relies on the provided API.

Insecure way

While not recommended due to security issues, you can set igist-auth-marker and igist-current-user-name in your Emacs config file:

(setq igist-current-user-name "your-github-username")
(setq igist-auth-marker "your-github-oauth-token")

Example with use-package.

(use-package igist
  :config
  (let ((default-directory user-emacs-directory))
    (condition-case nil
        (progn (setq igist-current-user-name
                     (car-safe
                      (process-lines "git"
                                     "config"
                                     "user.name")))
               (setq igist-auth-marker
                     (or (ignore-errors
                           (car-safe (process-lines "git" "config"
                                                    "github.oauth-token")))
                         igist-auth-marker)))
      (error (message "Igist-current-user-name cannot setted")))))

Important

In this method, your OAuth token will be stored as plain text in your emacs config file, which is insecure. Ensure your config file permissions are appropriately set to prevent unauthorized access.

Usage

With the authentication properly configured, you can now use igist. The simplest way is to invoke a transient popup with the list of available commands for the current buffer:

  • M-x igist-dispatch - in igists buffers it is bound to M-o.

List gists

There are two ways in which gists can be presented - as a table or as minibuffer completions.

Table

  • M-x igist-list-gists - to display gists of logged GitHub user.
  • M-x igist-explore-public-gists - list public gists sorted by most recently updated to least recently updated. ./igist-explore-demo.png
  • M-x igist-list-other-user-gists - to display public gists of non-logged user.

This commands render and load gists with pagination. To stop or pause loading use command igist-list-cancel-load (default keybinding is K).

KeyDescriptionCommand
RETedit gist at pointigist-list-edit-gist-at-point-async
v or C-jview gist at pointigist-list-view-current
<backtab>toggle all childrenigist-toggle-all-children
<tab>toggle row children at pointigist-toggle-row-children-at-point
+add file to gistigist-list-add-file
-delete current filenameigist-delete-current-filename
Ddelete current gistigist-delete-current-gist
Sstar gistigist-star-gist
Uunstar gistigist-unstar-gist
aadd commentigist-add-comment
cload commentsigist-load-comments
dedit descriptionigist-list-edit-description
ffork gistigist-fork-gist
wcopy gist urligist-copy-gist-url
rbrowse gistigist-browse-gist
Lclone gistigist-clone-gist
?open transient menu with main commandsigist-dispatch
Copen transient menu for editing UIigist-table-menu
/open transient menu for filteringigist-filters-menu
Kcancel loadigist-list-cancel-load
grefresh gistsigist-list-refresh
ssort gistigist-tabulated-list-sort
Gforce rerenderigist-tabulated-list-revert
}widen current columnigist-tabulated-list-widen-current-column
{narrow current columnigist-tabulated-list-narrow-current-column
M-] or M-}swap column with the next oneigist-swap-current-column
M-[ or M-{swap column with the previous oneigist-swap-current-column-backward
C-M-nforward gist and previewigist-list-forward-row-and-preview
C-M-pbackward gist and previewigist-list-backward-row-and-preview
nmove to next linenext-line
pmove to previous lineprevious-line
C-M-fforward to next columnigist-tabulated-forward-column
C-M-bmove to the previous columnigist-tabulated-backward-column

To customize these keys, see the variable igist-list-mode-map.

You can change the width, reorder, or remove columns interactively with the transient menu - igist-table-menu. If you want to save your settings, use the command M-x igist-save-column-settings. To discard, use M-x igist-reset-columns-settings.

Minibuffer Completions

  • M-x igist-edit-list - read Gist to edit from the minibuffer.

Ivy users can also use igist-ivy-read-public-gists and igist-ivy-read-user-gists.

Edit gist

You can view, edit and save gists in buffers with igist-edit-mode. This minor mode is turned on after command igist-edit-gist and igist-edit-list.

KeyCommand
M-otransient popup
C-c C-csave and exit
C-c 'save and exit
C-x C-ssave without exiting

To customize these keys see the variable igist-edit-mode-map.

List comments

This minor mode is turned on after command igist-load-comments.

In comments list mode, such commands are available:

KeyCommand
+add comment
-delete the comment at point
Ddelete the comment at point
eadd or edit
grefresh comments

To customize these keybindings edit the variable igist-comments-list-mode-map.

Editing comment

This minor mode is turned on after commands igist-edit-comment and igist-add-comment. Keymap for posting and editing comments:

KeyCommand
C-c C-cpost comment

To customize these keybindings edit the variable igist-comments-edit-mode-map.

Customization

  • igist-current-user-name: This variable should be set to a string that contains your GitHub username.
  • igist-auth-marker: This variable can either be a string that contains the OAuth token or a symbol indicating where to retrieve the OAuth token.
  • igist-message-function: A custom function for displaying messages. Should accept the same arguments as the message function.
  • igist-per-page-limit: The number of results to fetch per page. The default value is 30.
  • igist-ask-for-description: Determines when to prompt for a description before posting new gists. The default setting prompts for a description before saving a new gist.
  • igist-enable-copy-gist-url-p: Specifies whether and when to add the URL of a new or updated gist to the kill ring. The default setting is after the creation of new gists.
  • igist-list-format: Specifies the format of the user’s Tabulated Gists buffers.
  • igist-explore-format: Specifies the format of the Explore Public Gists tabulated buffers.
  • igist-immediate-resize-strategy: Controls the resizing strategy for tabulated entries when using igist-tabulated-list-widen-current-column.
  • igist-user-gists-init-collapsed: Whether the gists should be collapsed by default in user buffers.
  • igist-explore-gists-init-collapsed: Whether the gists should be collapsed by default in explore buffers.
  • igist-clone-default-directory: Default directory to use when igist-clone-gist reads destination.
  • igist-use-header-line: Whether the IGist List buffer should use a header line. If nil, an overlay will be used.
  • igist-tabulated-list-padding: Number of characters preceding each IGist List mode entry.
  • igist-tabulated-list-tty-sort-indicator-desc: Indicator for columns sorted in ascending order, for text-mode frames.
  • igist-tabulated-list-tty-sort-indicator-asc: Indicator for columns sorted in ascending order, for text-mode frames.
  • igist-tabulated-list-gui-sort-indicator-desc: Indicator for columns sorted in descending order, for gui frames.
  • igist-tabulated-list-gui-sort-indicator-asc: Indicator for columns sorted in ascending order, for gui frames.

Comparison with other Emacs Gist Libraries

Several Emacs packages for GitHub gists already exist (gist.el, jist.el, yagist.el).

igist not only includes the core functionalities of managing gists - such as editing, listing, and creating - but also introduces many new features.

  • Transient Command Interface: By adopting the transient command interface, igist provides context-aware actions for managing GitHub Gists. The use of transient interfaces leads to smoother task flows, reduces the need for keystrokes, and offers a more intuitive user experience.
  • Asynchronous Advanced Rendering: igist presents advanced rendering capabilities, including incremental and asynchronous loading and rendering. This ensures that the Emacs interface remains responsive even when handling a large number of Gists.
  • Customization on the Fly: igist focuses on providing an interface for live configuration of how gists should be displayed. Users can adjust column width and alignment, alter sortability, and add, rename or remove columns on the fly.
  • Incremental Filtering: This feature allows filtering of Gists by filename, description, or programming language.

igist's People

Contributors

karimaziev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

emacsmirror amno1

igist's Issues

How to set default user?

Hi, first of all, thank you very much for this awesome package!
As far as I understand I have to set igist-current-user-name before I can use all gist functions. Also it seems I have to set it each time after emacs restart. I have only one account and it would be convenient for me to set this one user automatically.
Did not find a way to set default user automatically.

[BUG]

Describe the bug
igist list sometimes does not load and returns empty list after spending a lot of time behind the scenes

To Reproduce
Steps to reproduce (if applicable)

Expected behavior
First time it works. Many times refreshing the gist list does not work

Relevant Version Numbers

  • igist: 20231114.928
  • ghub: 20231026.1306
  • transient: 20230901.1237

Stacktrace (if applicable):

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Emacs version: 29.1
  • Package version: ?
  • Operating system: macOS 10.15

BACKGROUND in docstring may have some issues

Hi, this package is very useful to me and I use it for single-file emacs config with gist.

When I read some docstring in igist.el, I noticed that BACKGROUND appears in igist-list-load-gists, igist-list-request, igist-explore-public-gists and igist-list-starred's docstring, the first, thrid and fourth said that If BACKGROUND is nil, don't show user's buffer., but I think it should be If BACKGROUND is non-nil, don't show buffer. Since in igist-list-request the variable backgroun is used like this:

 (unless background
          (igist-ensure-buffer-visible buffer))))))

Also, BACKGROUND in igist-list-starred's docstring could be deleted, because there is no background arg in arglist.

Regards.

Making `igist-current-user-name` customizable

Hi, first of all great package.

Related to #3, of course one can set igist-current-user-name manually, but please consider making the variable a customized variable instead of defvar which helps people both to discover it and to explicitly set it, because it is really not encouraged for end users to explicitly set defvar variables as part of their configuration; just a convention issue.

Since it's probably a common issue (users having a single, main github profile) maybe show that example in the readme. Thanks!

Is this working with .authinfo?

Have you been using this lately?

I have a GH token and have setup .authinfo according the instructions in the readme: amno1^igist and a GH token with the gist priviledge, however when I run any of listing functions, which all are routing through igist-list-request, I get a json filled with data from a bunch bot accounts?

[{"url":"https://api.github.com/gists/20fb17a13c2e219a0f4d2990d6fd106d","forks_url":"https://api.github.com/gists/20fb17a13c2e219a0f4d2990d6fd106d/forks","commits_url":"https://api.github.com/gists/20fb17a13c2e219a0f4d2990d6fd106d/commits","id":"20fb17a13c2e219a0f4d2990d6fd106d","node_id":"G_kwDOCQw3VdoAIDIwZmIxN2ExM2MyZTIxOWEwZjRkMjk5MGQ2ZmQxMDZk","git_pull_url":"https://gist.github.com/20fb17a13c2e219a0f4d2990d6fd106d.git","git_push_url":"https://gist.github.com/20fb17a13c2e219a0f4d2990d6fd106d.git","html_url":"https://gist.github.com/MixDark/20fb17a13c2e219a0f4d2990d6fd106d","files":{"flor_espiral.py":{"filename":"flor_espiral.py","type":"application/x-python","language":"Python","raw_url":"https://gist.githubusercontent.com/MixDark/20fb17a13c2e219a0f4d2990d6fd106d/raw/b284dfe1b2ab8909282e9cba673e071fd9739885/flor_espiral.py","size":347}},"public":true,"created_at":"2024-06-22T14:07:59Z","updated_at":"2024-06-22T14:07:59Z","description":"Flor espiral","comments":0,"user":null,"comments_url":"https://api.github.com/gists/20fb17a13c2e219a0f4d2990d6fd106d/comments","owner":{"login":"MixDark","id":151795541,"node_id":"U_kgDOCQw3VQ","avatar_url":"https://avatars.githubusercontent.com/u/151795541?v=4","gravatar_id":"","url":"https://api.github.com/users/MixDark","html_url":"https://github.com/MixDark","followers_url":"https://api.github.com/users/MixDark/followers","following_url":"https://api.github.com/users/MixDark/following{/other_user}","gists_url":"https://api.github.com/users/MixDark/gists{/gist_id}","starred_url":"https://api.github.com/users/MixDark/starred{/owner}{/repo}",

The above is just few first lines. Any idea, why is that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.