expand usage of urlutils.get_url_yank_text
This commit is contained in:
parent
3dc80fa192
commit
5801d4b532
|
|
@ -27,6 +27,10 @@ Fixed
|
|||
- Setting `url.auto_search` to `dns` works correctly now with Qt 6.
|
||||
- Counts passed via keypresses now have a digit limit (4300) to avoid
|
||||
exceptions due to cats sleeping on numpads. (#7834)
|
||||
- Ignored URL query parameters (via `url.yank_ignored_parameters`) are now
|
||||
respected when yanking any URL (for example, through hints with `hint links
|
||||
yank`). The `{yank_url}` subsitution has also been added as a version of
|
||||
`{url}` that respects ignored URL query parameters. (#7879)
|
||||
|
||||
[[v3.0.0]]
|
||||
v3.0.0 (2023-08-18)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ For command arguments, there are also some variables you can use:
|
|||
- `{url:host}`, `{url:domain}`, `{url:auth}`, `{url:scheme}`, `{url:username}`,
|
||||
`{url:password}`, `{url:port}`, `{url:path}` and `{url:query}`
|
||||
expand to the respective parts of the current URL
|
||||
- `{yank_url}` expands to the URL of the current page but strips all the query
|
||||
parameters in the `url.yank_ignored_parameters` setting.
|
||||
- `{title}` expands to the current page's title
|
||||
- `{clipboard}` expands to the clipboard contents
|
||||
- `{primary}` expands to the primary selection contents
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from qutebrowser.qt.core import pyqtSlot, QUrl, QObject
|
|||
|
||||
from qutebrowser.api import cmdutils
|
||||
from qutebrowser.commands import cmdexc, parser
|
||||
from qutebrowser.utils import message, objreg, qtutils, usertypes, utils
|
||||
from qutebrowser.utils import message, objreg, qtutils, usertypes, utils, urlutils
|
||||
from qutebrowser.keyinput import macros, modeman
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -57,6 +57,7 @@ def _init_variable_replacements() -> Mapping[str, _ReplacementFunction]:
|
|||
_url(tb).port()) if _url(tb).port() != -1 else "",
|
||||
'url:path': lambda tb: _url(tb).path(),
|
||||
'url:query': lambda tb: _url(tb).query(),
|
||||
'yank_url': lambda tb: urlutils.get_url_yank_text(_url(tb), False),
|
||||
'title': lambda tb: tb.widget.page_title(tb.widget.currentIndex()),
|
||||
'clipboard': lambda _: utils.get_clipboard(),
|
||||
'primary': lambda _: utils.get_clipboard(selection=True),
|
||||
|
|
|
|||
|
|
@ -2554,7 +2554,7 @@ url.yank_ignored_parameters:
|
|||
- utm_term
|
||||
- utm_content
|
||||
- utm_name
|
||||
desc: URL parameters to strip with `:yank url`.
|
||||
desc: URL parameters to strip when yanking a URL.
|
||||
|
||||
## window
|
||||
|
||||
|
|
@ -3716,8 +3716,8 @@ bindings.default:
|
|||
yD: yank domain -s
|
||||
yp: yank pretty-url
|
||||
yP: yank pretty-url -s
|
||||
ym: yank inline [{title}]({url})
|
||||
yM: yank inline [{title}]({url}) -s
|
||||
ym: yank inline [{title}]({yank_url})
|
||||
yM: yank inline [{title}]({yank_url}) -s
|
||||
pp: open -- {clipboard}
|
||||
pP: open -- {primary}
|
||||
Pp: open -t -- {clipboard}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import dataclasses
|
|||
from typing import Deque, MutableSequence, Optional, cast
|
||||
|
||||
from qutebrowser.qt.core import (pyqtSlot, pyqtSignal, Qt, QTimer, QDir, QModelIndex,
|
||||
QItemSelectionModel, QObject, QEventLoop)
|
||||
QItemSelectionModel, QObject, QEventLoop, QUrl)
|
||||
from qutebrowser.qt.widgets import (QWidget, QGridLayout, QVBoxLayout, QLineEdit,
|
||||
QLabel, QTreeView, QSizePolicy,
|
||||
QSpacerItem)
|
||||
|
|
@ -23,7 +23,7 @@ from qutebrowser.config import config, configtypes, configexc, stylesheet
|
|||
from qutebrowser.utils import usertypes, log, utils, qtutils, objreg, message
|
||||
from qutebrowser.keyinput import modeman
|
||||
from qutebrowser.api import cmdutils
|
||||
from qutebrowser.utils import urlmatch
|
||||
from qutebrowser.utils import urlmatch, urlutils
|
||||
|
||||
|
||||
prompt_queue = cast('PromptQueue', None)
|
||||
|
|
@ -443,8 +443,9 @@ class PromptContainer(QWidget):
|
|||
else:
|
||||
sel = False
|
||||
target = 'clipboard'
|
||||
utils.set_clipboard(question.url, sel)
|
||||
message.info("Yanked to {}: {}".format(target, question.url))
|
||||
url_str = urlutils.get_url_yank_text(QUrl(question.url), False)
|
||||
utils.set_clipboard(url_str, sel)
|
||||
message.info("Yanked to {}: {}".format(target, url_str))
|
||||
|
||||
@cmdutils.register(
|
||||
instance='prompt-container', scope='window',
|
||||
|
|
|
|||
Loading…
Reference in New Issue