NeoMutt  2025-12-11-872-g385a04
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
commands.c
Go to the documentation of this file.
1
23
29
30#include "config.h"
31#include <stdbool.h>
32#include "private.h"
33#include "mutt/lib.h"
34#include "core/lib.h"
35#include "parse/lib.h"
36#include "module_data.h"
37#include "muttlib.h"
38
45enum CommandResult parse_sidebar_pin(const struct Command *cmd, struct Buffer *line,
46 const struct ParseContext *pc, struct ParseError *pe)
47{
49 struct Buffer *err = pe->message;
50
51 if (!MoreArgs(line))
52 {
53 buf_printf(err, _("%s: too few arguments"), cmd->name);
54 return MUTT_CMD_WARNING;
55 }
56
57 struct Buffer *path = buf_pool_get();
58
59 do
60 {
62 expand_path(path, false);
63 add_to_stailq(&mod_data->sidebar_pinned, buf_string(path));
64 } while (MoreArgs(line));
65 buf_pool_release(&path);
66
67 return MUTT_CMD_SUCCESS;
68}
69
76enum CommandResult parse_sidebar_unpin(const struct Command *cmd, struct Buffer *line,
77 const struct ParseContext *pc, struct ParseError *pe)
78{
80 struct Buffer *err = pe->message;
81
82 if (!MoreArgs(line))
83 {
84 buf_printf(err, _("%s: too few arguments"), cmd->name);
85 return MUTT_CMD_WARNING;
86 }
87
88 struct Buffer *path = buf_pool_get();
89
90 do
91 {
93 /* Check for deletion of entire list */
94 if (mutt_str_equal(buf_string(path), "*"))
95 {
97 break;
98 }
99 expand_path(path, false);
101 } while (MoreArgs(line));
102 buf_pool_release(&path);
103
104 return MUTT_CMD_SUCCESS;
105}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
CommandResult
Error codes for command_t parse functions.
Definition command.h:37
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition command.h:40
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition command.h:39
Convenience wrapper for the core headers.
int parse_extract_token(struct Buffer *dest, struct Buffer *line, TokenFlags flags)
Extract one token from a string.
Definition extract.c:49
#define MoreArgs(buf)
Definition extract.h:31
@ TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition extract.h:57
enum CommandResult parse_sidebar_pin(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'sidebar-pin' command - Implements Command::parse() -.
Definition commands.c:45
enum CommandResult parse_sidebar_unpin(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'sidebar-unpin' command - Implements Command::parse() -.
Definition commands.c:76
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition list.c:341
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition list.c:316
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition list.c:123
@ MODULE_ID_SIDEBAR
ModuleSidebar, Sidebar
Definition module_api.h:91
Convenience wrapper for the library headers.
#define _(a)
Definition message.h:28
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:122
Some miscellaneous functions.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
Text parsing functions.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
Sidebar private Module data.
GUI display the mailboxes in a side panel.
String manipulation buffer.
Definition buffer.h:36
const char * name
Name of the Command.
Definition command.h:162
Container for Accounts, Notifications.
Definition neomutt.h:41
Context for config parsing (history/backtrace)
Definition pcontext.h:34
Detailed error information from config parsing.
Definition perror.h:34
struct Buffer * message
Error message.
Definition perror.h:35
Sidebar private Module data.
Definition module_data.h:32
struct ListHead sidebar_pinned
List of mailboxes to always display in the sidebar.
Definition module_data.h:36