diff --git a/browse-at-remote.el b/browse-at-remote.el index 26d7001..fc1d15b 100644 --- a/browse-at-remote.el +++ b/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 -;; 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 @@ -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. @@ -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.")))) diff --git a/readme.rst b/readme.rst index f251abb..fbaf854 100644 --- a/readme.rst +++ b/readme.rst @@ -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. @@ -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 ---------------------- @@ -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`_. @@ -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: -----