NeoMutt  2025-12-11-694-ga89709
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 "muttlib.h"
37
44enum CommandResult parse_sidebar_pin(const struct Command *cmd, struct Buffer *line,
45 const struct ParseContext *pc, struct ParseError *pe)
46{
47 struct Buffer *err = pe->message;
48
49 if (!MoreArgs(line))
50 {
51 buf_printf(err, _("%s: too few arguments"), cmd->name);
52 return MUTT_CMD_WARNING;
53 }
54
55 struct Buffer *path = buf_pool_get();
56
57 do
58 {
60 expand_path(path, false);
62 } while (MoreArgs(line));
63 buf_pool_release(&path);
64
65 return MUTT_CMD_SUCCESS;
66}
67
74enum CommandResult parse_sidebar_unpin(const struct Command *cmd, struct Buffer *line,
75 const struct ParseContext *pc, struct ParseError *pe)
76{
77 struct Buffer *err = pe->message;
78
79 if (!MoreArgs(line))
80 {
81 buf_printf(err, _("%s: too few arguments"), cmd->name);
82 return MUTT_CMD_WARNING;
83 }
84
85 struct Buffer *path = buf_pool_get();
86
87 do
88 {
90 /* Check for deletion of entire list */
91 if (mutt_str_equal(buf_string(path), "*"))
92 {
94 break;
95 }
96 expand_path(path, false);
98 } while (MoreArgs(line));
99 buf_pool_release(&path);
100
101 return MUTT_CMD_SUCCESS;
102}
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 TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition extract.h:53
#define MoreArgs(buf)
Definition extract.h:31
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:44
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:74
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
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.
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
GUI display the mailboxes in a side panel.
struct ListHead SidebarPinned
List of mailboxes to always display in the sidebar.
Definition sidebar.c:44
String manipulation buffer.
Definition buffer.h:36
const char * name
Name of the Command.
Definition command.h:159
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