From e26d3d40b955f71d1df2d598bff7880ce71076bf Mon Sep 17 00:00:00 2001 From: Oldes Date: Thu, 18 Nov 2021 22:34:45 +0100 Subject: [PATCH] FIX: include user context values in the `help` output resolves: https://github.com/Oldes/Rebol-issues/issues/1155 --- src/mezz/mezz-help.reb | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/mezz/mezz-help.reb b/src/mezz/mezz-help.reb index e9fb4d0586..76057dd2bd 100644 --- a/src/mezz/mezz-help.reb +++ b/src/mezz/mezz-help.reb @@ -124,10 +124,10 @@ import module [ /weak "Provides sorting and does not displays unset values" /match "Include only those that match a string or datatype" pattern - /only {Do not display "no info" message} - /local start wild type str result + /local start wild type str result user? ][ result: clear "" + user?: same? obj system/contexts/user ; Search for matching strings: wild: all [string? pattern find pattern "*"] foreach [word val] obj [ @@ -150,6 +150,9 @@ import module [ type = :pattern ] ][ + ; don't show user context values if these are same like library ones + if all [user? any [ word = 'lib-local same? val select system/contexts/lib word]][ continue ] + str: join "^[[1;32m" form-pad word 15 append str "^[[m " append str form-pad type 11 - min 0 ((length? str) - 15) @@ -161,9 +164,7 @@ import module [ ] ] ] - either all [pattern empty? result not only] [ - ajoin ["No information on: ^[[32m" pattern "^[[m^/"] - ][ copy result ] + copy result ] out-description: func [des [block!]][ @@ -179,12 +180,11 @@ import module [ 'word [any-type!] /into "Help text will be inserted into provided string instead of printed" string [string!] "Returned series will be past the insertion" - /local value spec args refs rets type ret desc arg def des ref str cols + /local value spec args refs rets type ret desc arg def des ref str cols tmp ][ ;@@ quering buffer width in CI under Windows now throws error: `Access error: protocol error: 6` ;@@ it should return `none` like under Posix systems! - cols: try [ query/mode system/ports/input 'buffer-cols ] - unless integer? cols [ cols: 120 ] + cols: any [ attempt [ query/mode system/ports/input 'buffer-cols ] 120] max-desc-width: cols - 35 buffer: any [string clear ""] catch [ @@ -209,7 +209,20 @@ import module [ ][ word: mold :word ] ;or use it as a string input ] string? :word [ - output dump-obj/weak/match system/contexts/lib :word + tmp: false + case/all [ + not empty? value: dump-obj/weak/match system/contexts/lib :word [ + output ajoin ["Found these related matches:^/" value] + tmp: true + ] + not empty? value: dump-obj/weak/match system/contexts/user :word [ + output ajoin ["Found these related matches in the user context:^/" value] + tmp: true + ] + not tmp [ + output ajoin ["No information on: ^[[32m" :word "^[[m^/"] + ] + ] throw true ] datatype? :value [ @@ -226,9 +239,12 @@ import module [ "It is defined as" either find "aeiou" first spec/title [" an "] [" a "] spec/title ".^/" "It is of the general type ^[[1;32m" spec/type "^[[m.^/^/" ] - unless empty? value: dump-obj/match/only system/contexts/lib :word [ + unless empty? value: dump-obj/match system/contexts/lib :word [ output ajoin ["Found these related words:^/" value] ] + unless empty? value: dump-obj/match system/contexts/user :word [ + output ajoin ["Found these related words in the user context:^/" value] + ] ] throw true ]