Skip to content

Commit

Permalink
bugfixes, release-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
inimino committed Jun 18, 2024
1 parent 3e80ee6 commit 0a0b6c9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cmpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ void call_llm(span model, json messages, void (*cb)(span)) {
In this function, we check that the file ~/.cmpr/openai-key exists and has the correct permissions.
Specifically, it should have read permissions only for the owner, which must be the current user.
@- Specifically, it should not have read permissions for any other user.
@- How much do we care about this?
We use null-terminated strings and standard C library functions for all of this.
Expand All @@ -639,7 +640,8 @@ void read_openai_key() {
const char* key_path = ".cmpr/openai-key";
struct stat st;

if (stat(key_path, &st) == -1 || st.st_mode != (S_IRUSR | S_IFREG) || st.st_uid != getuid()) {
//if (stat(key_path, &st) == -1 || st.st_mode != (S_IRUSR | S_IFREG) || st.st_uid != getuid()) {
if (stat(key_path, &st) == -1) {
return;
}

Expand Down Expand Up @@ -3696,6 +3698,7 @@ void keyboard_help() {
prt("B - Build project with provided command\n");
//prt("v - Toggle visual selection mode\n");
prt("/ - Enter search mode\n");
prt("# - Open block id jump list\n");
prt(": - Enter ex command line\n");
prt("n - Repeat search forward\n");
prt("N - Repeat search backward\n");
Expand Down Expand Up @@ -3890,10 +3893,10 @@ void handle_ex_command() {
select_model();
} else if (span_eq(state->ex_command, S(":expand"))) {
ex_expand();
} else if (span_eq(state->ex_command, S(":toprefs"))) {
ex_toprefs();
} else if (span_eq(state->ex_command, S(":inrefs"))) {
ex_inrefs();
//} else if (span_eq(state->ex_command, S(":toprefs"))) {
// ex_toprefs();
//} else if (span_eq(state->ex_command, S(":inrefs"))) {
// ex_inrefs();
}
state->ex_command = nullspan();
}
Expand All @@ -3919,8 +3922,8 @@ void ex_help() {
prt(":help - Print short help on available ex commands.\n");
prt(":model - Select the LLM to use for \"r\" and other commands.\n");
prt(":expand - Expands block references and displays the expanded result.\n");
prt(":toprefs - Expands and displays the top-line block references in a single markdown code block.\n");
prt(":inrefs - Expands and displays this block with inline block references expanded.\n");
//prt(":toprefs - Expands and displays the top-line block references in a single markdown code block.\n");
//prt(":inrefs - Expands and displays this block with inline block references expanded.\n");
flush();
prt("Press any key to continue...");
flush();
Expand Down
1 change: 1 addition & 0 deletions conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ language: Markdown
file: systemprompt
file: DATALOSS.md
file: README.md
file: release-notes.md
file: doc/FE.md
file: doc/plans.txt
18 changes: 18 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#v8

### Block references

Block references are now supported.
There are two kinds, "inline" and "topline".
The inline refs are created by writing "@blockid" on a line alone in the NL code, while the topline refs are created by putting the "@blockid" ref on the top line of the block.
Block ids themselves are always created by writing "#blockid" on the top line of the block.
Blocks can have more than one id.
The best way to see these features for now is to check the cmpr source itself for examples.
You can use the ":expand" ex command in cmpr to see how the block you're looking at looks when expanded.
This can be a useful way to check some references quickly yourself.
You can use "@blockid:code" to include the PL section of the block instead of the natural language section, and "@blockid:all" to include both.

### Block ids

Block ids with the "hashtag syntax", like "#block\_id" are now a supported feature.
In addition to the block references feature using them, they are also used by the "#" keybinding, which lets you see and jump quickly to any block that has an id.

0 comments on commit 0a0b6c9

Please sign in to comment.