Merge pull request #800 from torhve/bpin

Buffer pinning
This commit is contained in:
Lorenz Hübschle-Schneider 2016-09-27 15:51:05 +02:00
commit f98dc97737
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-&lt;</kbd>: Switch to previous active buffer</li>
<li><kbd>ALT-g</kbd>: Focus on buffer list filter</li> <li><kbd>ALT-g</kbd>: Focus on buffer list filter</li>
<li><kbd>Esc-Esc</kbd>: Disconnect (double-tap)</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><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> <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> </ul>
<h3>Pinning buffers</h3>
<p>
The option "Only show buffers with unread messages" is useful when you have a lot of buffers and can't 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 buffers get recreated. To unpin, you can use the same command and set anything other than <code>true</code>.
</p>
<p>
Helpful trigger to automatically repin a buffer (in this instance, <var>irc.freenode.#weechat</var>): <pre><code>/trigger add autopin signal "buffer_opened" "${buffer[${tg_signal_data}].full_name} =~ <var>irc.freenode.#weechat</var>" "" "/command -buffer ${buffer[${tg_signal_data}].full_name} * /buffer set localvar_set_pinned true"</code></pre>
</p>
</div> </div>
</div> </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')) { if (buffer.fullName === "core.weechat" || (settings.orderbyserver && buffer.type === 'server')) {
return true; return true;
} }
// Always show pinned buffers
if (buffer.pinned) {
return true;
}
return (buffer.unread > 0 || buffer.notification > 0) && !buffer.hidden; return (buffer.unread > 0 || buffer.notification > 0) && !buffer.hidden;
} }
return !buffer.hidden; return !buffer.hidden;

View file

@ -306,6 +306,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
old.server = localvars.server; old.server = localvars.server;
old.serverSortKey = old.plugin + "." + old.server + old.serverSortKey = old.plugin + "." + old.server +
(old.type === "server" ? "" : ("." + old.shortName)); (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 plugin = message.local_variables.plugin;
var server = message.local_variables.server; var server = message.local_variables.server;
var pinned = message.local_variables.pinned === "true";
// Server buffers have this "irc.server.freenode" naming schema, which // Server buffers have this "irc.server.freenode" naming schema, which
// messes the sorting up. We need it to be "irc.freenode" instead. // messes the sorting up. We need it to be "irc.freenode" instead.
var serverSortKey = plugin + "." + server + var serverSortKey = plugin + "." + server +
@ -335,7 +338,8 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
getHistoryUp: getHistoryUp, getHistoryUp: getHistoryUp,
getHistoryDown: getHistoryDown, getHistoryDown: getHistoryDown,
isNicklistEmpty: isNicklistEmpty, isNicklistEmpty: isNicklistEmpty,
nicklistRequested: nicklistRequested nicklistRequested: nicklistRequested,
pinned: pinned,
}; };
}; };