commit 473d64529c43cb9424e9fc574760a8aa16593449
parent d6cb4e35a118b0bbced25f3530758b8944be4f79
Author: Lou Woell <lou.woell@posteo.de>
Date:   Thu,  4 Sep 2025 23:33:22 +0200

Cleanup

Diffstat:
Mcmd/harehelper/find.ha | 4+++-
Mcmd/harehelper/locate.ha | 18+++++++++---------
Mcmd/harehelper/util.ha | 2+-
Mharedoc.el | 11+++++++----
4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/cmd/harehelper/find.ha b/cmd/harehelper/find.ha @@ -12,6 +12,7 @@ use os; fn resolve(cmd: getopt::command) void = { let id = parse::identstr(cmd.args[0])!; + let file = if(len(cmd.args) > 1){ yield cmd.args[1]; } else { @@ -22,6 +23,7 @@ fn resolve(cmd: getopt::command) void = { match(find_uid(id, file)) { case let id_exp: ast::ident => printident(id_exp); + ast::ident_free(id_exp); case => void; }; }; @@ -71,7 +73,7 @@ fn find_uid (id: ast::ident, path: str) (void | ast::ident) = { if(!check){ check = ast::ident_eq(ns, ident) || - ast::ident_eq(ns, ident_last(ident)); + ast::ident_eq(ns, ident_last(ident)); }; if (check) { diff --git a/cmd/harehelper/locate.ha b/cmd/harehelper/locate.ha @@ -1,11 +1,11 @@ -use hare::module; -use hare::lex; -use hare::ast; +use fmt; use getopt :: { command }; +use hare::ast; +use hare::lex; +use hare::module; use hare::parse; -use fmt; -use path; use os; +use path; fn locate (cmd: command, ctx: *module::context) void = { @@ -20,7 +20,7 @@ fn locate (cmd: command, ctx: *module::context) void = { case void => return void; case let d: lex::location => - fmt::printfln("{}:{}", d.path, d.line)!; + fmt::printfln("{}:{}:{}", d.path, d.line, d.col)!; }; }; @@ -35,7 +35,7 @@ fn locate_symbol ( ns = &p; }; - let (path, src) = match(module::find(ctx, ns)){ + let (path, src) = match(module::find(ctx, ns)) { case module::error => return void; case let r: (str, module::srcset) => @@ -52,7 +52,7 @@ fn locate_symbol ( for (let decl .. decls) { match(decl.decl){ - case let d: []ast::decl_const => + case let d: []ast::decl_const => for (let t .. d) { if(ast::ident_eq(id, t.ident)){ return decl.start; @@ -70,7 +70,7 @@ fn locate_symbol ( return decl.start; }; }; - case let d: ast::decl_func => + case let d: ast::decl_func => if(ast::ident_eq(id, d.ident)){ return decl.start; }; diff --git a/cmd/harehelper/util.ha b/cmd/harehelper/util.ha @@ -35,7 +35,7 @@ fn scan(path: str) ([]ast::decl | parse::error) = { let sc = bufio::newscanner(input); defer bufio::finish(&sc); let lexer = lex::init(&sc, path, lex::flag::NONE); - let su = parse::subunit(&lexer)?; + let su = parse::subunit(&lexer)?; ast::imports_finish(su.imports); return su.decls; }; diff --git a/haredoc.el b/haredoc.el @@ -99,12 +99,15 @@ the results in a new buffer." (hare/root-dir) "locate" name)) ":")) - (file (car loc)) - (line (string-to-number (cadr loc)))) + (file (nth 0 loc)) + (line (string-to-number (nth 1 loc))) + (col (string-to-number (nth 2 loc)))) (when (not (string= file "")) (with-current-buffer (find-file file) - (print file) - (goto-line line))))) + (goto-char (point-min)) + (forward-line (1- line)) + (forward-char col) + (forward-to-word))))) (define-derived-mode haredoc-mode help-mode "🐇")