mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a scratch buffer to the history ring. (closes #3082)

This patch creates an extra slot in the history ring for a scratch
buffer (at h->last). If you are editing inside that buffer, it is
preserved when you scroll up/down through the history. Editing while in
other places in history are *not* preserved with this patch.

Another behavior change worth noting with this patch: the position in
history is now reset to the scratch buffer after each input entry.
Before, the position would be stay wherever it was - you didn't restart
at the "bottom" each time.

+61 -12
+3 -3
doc/manual.xml.head
··· 580 580 and can be made persistent using an external file specified using <link 581 581 linkend="history-file">$history_file</link>. You may cycle through them 582 582 at an editor prompt by using the <literal>&lt;history-up&gt;</literal> 583 - and/or <literal>&lt;history-down&gt;</literal> commands. But notice that 584 - Mutt does not remember the currently entered text, it only cycles 585 - through history and wraps around at the end or beginning. 583 + and/or <literal>&lt;history-down&gt;</literal> commands. Mutt will 584 + remember the currently entered text as you cycle through history, and 585 + will wrap around to the initial entry line. 586 586 </para> 587 587 588 588 <para>
+11
enter.c
··· 302 302 { 303 303 case OP_EDITOR_HISTORY_UP: 304 304 state->curpos = state->lastchar; 305 + if (mutt_history_at_scratch (hclass)) 306 + { 307 + my_wcstombs (buf, buflen, state->wbuf, state->curpos); 308 + mutt_history_save_scratch (hclass, buf); 309 + } 305 310 replace_part (state, 0, mutt_history_prev (hclass)); 306 311 redraw = M_REDRAW_INIT; 307 312 break; 308 313 309 314 case OP_EDITOR_HISTORY_DOWN: 310 315 state->curpos = state->lastchar; 316 + if (mutt_history_at_scratch (hclass)) 317 + { 318 + my_wcstombs (buf, buflen, state->wbuf, state->curpos); 319 + mutt_history_save_scratch (hclass, buf); 320 + } 311 321 replace_part (state, 0, mutt_history_next (hclass)); 312 322 redraw = M_REDRAW_INIT; 313 323 break; ··· 732 742 733 743 bye: 734 744 745 + mutt_reset_history_state (hclass); 735 746 FREE (&tempbuf); 736 747 return rv; 737 748 }
+44 -9
history.c
··· 45 45 { 46 46 if (h->hist) 47 47 { 48 - for (i = 0 ; i < OldSize ; i ++) 48 + for (i = 0 ; i <= OldSize ; i ++) 49 49 FREE (&h->hist[i]); 50 50 FREE (&h->hist); 51 51 } 52 52 } 53 53 54 54 if (HistSize) 55 - h->hist = safe_calloc (HistSize, sizeof (char *)); 55 + h->hist = safe_calloc (HistSize + 1, sizeof (char *)); 56 56 57 57 h->cur = 0; 58 58 h->last = 0; ··· 230 230 if (*s) 231 231 { 232 232 prev = h->last - 1; 233 - if (prev < 0) prev = HistSize - 1; 233 + if (prev < 0) prev = HistSize; 234 234 235 235 /* don't add to prompt history: 236 236 * - lines beginning by a space ··· 241 241 if (save && SaveHist) 242 242 save_history (hclass, s); 243 243 mutt_str_replace (&h->hist[h->last++], s); 244 - if (h->last > HistSize - 1) 244 + if (h->last > HistSize) 245 245 h->last = 0; 246 246 } 247 247 } ··· 257 257 return (""); /* disabled */ 258 258 259 259 next = h->cur + 1; 260 - if (next > HistSize - 1) 260 + if (next > HistSize) 261 261 next = 0; 262 - h->cur = h->hist[next] ? next : 0; 262 + if (h->hist[next] || (next == h->last)) 263 + h->cur = next; 264 + else 265 + h->cur = 0; 263 266 return (h->hist[h->cur] ? h->hist[h->cur] : ""); 264 267 } 265 268 ··· 274 277 prev = h->cur - 1; 275 278 if (prev < 0) 276 279 { 277 - prev = HistSize - 1; 278 - while (prev > 0 && h->hist[prev] == NULL) 280 + prev = HistSize; 281 + while ((prev > 0) && (prev != h->last) && (h->hist[prev] == NULL)) 279 282 prev--; 280 283 } 281 - if (h->hist[prev]) 284 + if (h->hist[prev] || (prev == h->last)) 282 285 h->cur = prev; 283 286 return (h->hist[h->cur] ? h->hist[h->cur] : ""); 284 287 } 288 + 289 + void mutt_reset_history_state (history_class_t hclass) 290 + { 291 + struct history *h = GET_HISTORY(hclass); 292 + 293 + if (!HistSize || !h) 294 + return; /* disabled */ 295 + 296 + h->cur = h->last; 297 + } 298 + 299 + int mutt_history_at_scratch (history_class_t hclass) 300 + { 301 + struct history *h = GET_HISTORY(hclass); 302 + 303 + if (!HistSize || !h) 304 + return 0; /* disabled */ 305 + 306 + return h->cur == h->last; 307 + } 308 + 309 + void mutt_history_save_scratch (history_class_t hclass, const char *s) 310 + { 311 + struct history *h = GET_HISTORY(hclass); 312 + 313 + if (!HistSize || !h) 314 + return; /* disabled */ 315 + 316 + /* Don't check if s has a value because the scratch buffer may contain 317 + * an old garbage value that should be overwritten */ 318 + mutt_str_replace (&h->hist[h->last], s); 319 + }
+3
history.h
··· 41 41 void mutt_history_add(history_class_t, const char *, int); 42 42 char *mutt_history_next(history_class_t); 43 43 char *mutt_history_prev(history_class_t); 44 + void mutt_reset_history_state (history_class_t); 45 + int mutt_history_at_scratch (history_class_t); 46 + void mutt_history_save_scratch (history_class_t, const char *); 44 47 45 48 #endif