@@ -910,6 +910,10 @@ proc cmdModuleLoad {context uasked tag_list args} {
910910 reportMsgRecord " Loading [ getModuleDesignation $msgrecid {}\
911911 2] "
912912 }
913+
914+ # apply missing tag to loaded module
915+ cmdModuleTag $tag_list $modname
916+
913917 # exit treatment but no need to restore settings
914918 set loadok 1
915919 continue
@@ -2348,6 +2352,64 @@ proc cmdModuleHelp {args} {
23482352 }
23492353}
23502354
2355+ proc cmdModuleTag {tag_list args} {
2356+ reportDebug " tagging $args (tag_list=$tag_list )"
2357+
2358+ set ret 0
2359+ foreach mod $args {
2360+ # find mod among loaded modules
2361+ lassign [getPathToModule $mod {} 1 match] modfile modname modnamevr\
2362+ errkind
2363+
2364+ if {$modfile eq {}} {
2365+ set ret 1
2366+ # go to next module to unload
2367+ continue
2368+ }
2369+
2370+ # record tags not already set
2371+ lassign [getDiffBetweenList $tag_list [getTagList $modname ]] diff_list
2372+ if {[llength $diff_list ] > 0} {
2373+ lappendState mode unload
2374+ # first unset tags declared for this module on LM env var
2375+ if {[set modtag [getExportTagList $modname 1]] ne {}} {
2376+ remove-path __MODULES_LMTAG $modtag
2377+ }
2378+ if {[set modtag [getExtraTagList $modname 1]] ne {}} {
2379+ remove-path __MODULES_LMEXTRATAG $modtag
2380+ }
2381+ lpopState mode
2382+
2383+ # record new tags as extra tag excluding tags relative to the way
2384+ # module is loaded (auto, keep)
2385+ lassign [getDiffBetweenList $diff_list [list auto-loaded\
2386+ keep-loaded]] extradiff_list
2387+ setModuleTag $modname {*}$diff_list
2388+ if {[llength $extradiff_list ] > 0} {
2389+ setModuleExtraTag $modname {*}$extradiff_list
2390+ }
2391+ if {$modnamevr ne {} && $modname ne $modnamevr } {
2392+ setModuleTag $modnamevr {*}$diff_list
2393+ if {[llength $extradiff_list ] > 0} {
2394+ setModuleExtraTag $modnamevr {*}$extradiff_list
2395+ }
2396+ }
2397+
2398+ # set the new tag set for module on LM env var
2399+ lappendState mode load
2400+ if {[set modtag [getExportTagList $modnamevr 1]] ne {}} {
2401+ append -path __MODULES_LMTAG $modtag
2402+ }
2403+ if {[set modtag [getExtraTagList $modnamevr 1]] ne {}} {
2404+ append -path __MODULES_LMEXTRATAG $modtag
2405+ }
2406+ lpopState mode
2407+ }
2408+ }
2409+
2410+ return $ret
2411+ }
2412+
23512413# ;;; Local Variables: ***
23522414# ;;; mode:tcl ***
23532415# ;;; End: ***
0 commit comments