Skip to content

Commit

Permalink
Add customization for line selection, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
rmuslimov committed Mar 8, 2020
1 parent 32d6a7e commit 771a307
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
18 changes: 14 additions & 4 deletions browse-at-remote.el
@@ -1,10 +1,10 @@
;;; browse-at-remote.el --- Open github/gitlab/bitbucket/stash/gist/phab/sourcehut page from Emacs -*- lexical-binding:t -*-

;; Copyright © 2015-2018 Rustem Muslimov
;; Copyright © 2015-2020
;;
;; Author: Rustem Muslimov <r.muslimov@gmail.com>
;; Version: 0.13.0
;; Keywords: github, gitlab, bitbucket, gist, stash, phabricator, sourcehut
;; Version: 0.14.0
;; Keywords: github, gitlab, bitbucket, gist, stash, phabricator, sourcehut, pagure
;; Package-Requires: ((f "0.17.2") (s "1.9.0") (cl-lib "0.5"))

;; This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -76,6 +76,14 @@ When nil, uses the commit hash. The contents will never change."
:type 'boolean
:group 'browse-at-remote)

(defcustom browse-at-remote-add-line-number-if-no-region-selected t
"Always add line number even if region is not selected in buffer.
When is option is t, bar-browse adds line number to URL even if region was not selected.
By default is true."
:type 'boolean
:group 'browse-at-remote)

(defun browse-at-remote--get-url-from-remote (remote-url)
"Return (DOMAIN . URL) from REMOTE-URL."
;; If the protocol isn't specified, git treats it as an SSH URL.
Expand Down Expand Up @@ -428,7 +436,9 @@ Currently the same as for github."
(if (eq (char-before point-end) ?\n) (- point-end 1) point-end))))

;; We're inside of file-attached buffer without region
(buffer-file-name (browse-at-remote--file-url (buffer-file-name)))
(buffer-file-name
(let ((line (when browse-at-remote-add-line-number-if-no-region-selected (point))))
(browse-at-remote--file-url (buffer-file-name) line)))

(t (error "Sorry, I'm not sure what to do with this."))))

Expand Down
27 changes: 22 additions & 5 deletions readme.rst
Expand Up @@ -29,9 +29,13 @@ Active keybindings for ``browse-at-remote`` function:::

(global-set-key (kbd "C-c g g") 'browse-at-remote)


Customization
-------------

Remote types
************

By default `browse-at-remote` knows how to work with popular remote types (github/gitlab..). Knowledge how to work with certain remote-type comes from mapping `browse-at-remote-remote-type-domains`. It defines that `github.com` should be treat in github manner, `bitbucket.org` in bitbucket manner and so on.
In your development you may have some specific git-url, and `browse-at-remote` will before confuse which remote-type map to your domain.

Expand Down Expand Up @@ -59,6 +63,16 @@ Two solution available:

git config --add browseAtRemote.type "stash"

Excluding line number if no region is selected
**********************************************

By default `browse-at-remote` add line number when region is not selected in file attached buffer. If you don't like that and what to see no line information URL, it's possible to disable that by adding:::

(setq browse-at-remote-add-line-number-if-no-region-selected nil)

Or setting via UI with `M-x customize`.


Adding new remote type
----------------------

Expand Down Expand Up @@ -126,6 +140,11 @@ Contributors:
Changelog:
--------

0.14.0
******
New remote type added **Pagure** by `@FrostyX`_.
New configuration option `browse-at-remote-add-line-number-if-no-region-selected` allowing add or not line number when target page open and region initially is not selected.

0.13.0
******
New remote type added **Sourcehut** by `@microamp`_.
Expand Down Expand Up @@ -156,17 +175,15 @@ Major refactorings by `@ieure`_. Main function renamed to `browse-at-remote/brow

0.6.0
*****
- Added support of Gitlab by `@env0der`_. Thanks!
Added support of Gitlab by `@env0der`_. Thanks!

0.5.0
*****

- Added support of Github Enterprice. Special thanks for `@env0der`_ for this feature.
Added support of Github Enterprice. Special thanks for `@env0der`_ for this feature.

0.4.0
*****

- Function `browse-at-remote/to-clipboard` were added (renamed in 0.8.0 to `bar-to-clibpoard`)
Function `browse-at-remote/to-clipboard` were added (renamed in 0.8.0 to `bar-to-clibpoard`)

TODO:
-----
Expand Down

0 comments on commit 771a307

Please sign in to comment.