Ability to pin buffers. Fixes #778.

This introduces ability to pin buffers using localvar storage in
WeeChat. At a later stage some UI should be introduced for this, like
discussed in #604 .
This commit is contained in:
Tor Hveem 2016-08-03 15:05:25 +02:00 committed by Lorenz Hübschle-Schneider
parent b917b74c3f
commit 65b4aaa97d
4 changed files with 23 additions and 2 deletions

View file

@ -152,10 +152,21 @@
<li><kbd>ALT-&lt;</kbd>: Switch to previous active buffer</li>
<li><kbd>ALT-g</kbd>: Focus on buffer list filter</li>
<li><kbd>Esc-Esc</kbd>: Disconnect (double-tap)</li>
<li>Arrow keys: Navigate history</li>
<li>Arrow keys: Navigate history, or navigate quick search buffer results.</li>
<li><kbd>Tab</kbd>: Complete nick</li>
<li>The following readline/emacs style keybindings can be enabled with a setting: <span title="Move cursor to beginning of line"><kbd>Ctrl-a</kbd></span>, <span title="Move cursor to te end of the line"><kbd>Ctrl-e</kbd></span>, <span title="Delete from cursor to beginning of the line"><kbd>Ctrl-u</kbd></span>, <span title="Delete from cursor to the end of the line"><kbd>Ctrl-k</kbd></span>, <span title="Delete from cursor to previous space"><kbd>Ctrl-w</kbd></span></li>
</ul>
<h3>Pinning buffers</h3>
<p>
The option "Only show buffers with unread messages" is useful when you have a lot of buffers and cant meaningfully look at all of them at the same time. However, often you have a select few buffers that you use more frequently and would like to have displayed permanently.
</p>
<p>
To pin a buffer, type <code>/buffer set localvar_set_pinned true</code>. <strong>Note</strong>: Local variables on buffers are not persisted across WeeChat restarts, so either use script <code>buffer_autoset.py</code> to automatically apply that upon buffer creation or use a trigger if you want automatic repinning when buffer gets recreated. To unpin you can use the same command and set anything other than true.
</p>
<p>
Helpful trigger for automatically repin buffer: <code>/trigger add autopin signal "buffer_opened" "${buffer[${tg_signal_data}].full_name} =~ irc.freenode.#weechat" "" "/command -buffer ${buffer[${tg_signal_data}].full_name} * /buffer set localvar_set_pinned true"</code>
</p>
</div>
</div>
</div>

View file

@ -680,6 +680,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
if (buffer.fullName === "core.weechat" || (settings.orderbyserver && buffer.type === 'server')) {
return true;
}
// Always show pinned buffers
if (buffer.pinned) {
return true;
}
return (buffer.unread > 0 || buffer.notification > 0) && !buffer.hidden;
}
return !buffer.hidden;

View file

@ -306,6 +306,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
old.server = localvars.server;
old.serverSortKey = old.plugin + "." + old.server +
(old.type === "server" ? "" : ("." + old.shortName));
old.pinned = localvars.pinned === "true";
}
};

View file

@ -95,6 +95,9 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
var plugin = message.local_variables.plugin;
var server = message.local_variables.server;
var pinned = message.local_variables.pinned === "true";
// Server buffers have this "irc.server.freenode" naming schema, which
// messes the sorting up. We need it to be "irc.freenode" instead.
var serverSortKey = plugin + "." + server +
@ -335,7 +338,8 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
getHistoryUp: getHistoryUp,
getHistoryDown: getHistoryDown,
isNicklistEmpty: isNicklistEmpty,
nicklistRequested: nicklistRequested
nicklistRequested: nicklistRequested,
pinned: pinned,
};
};