Compose: Allow modules to remove compose sequences

With this patch, the content of the .remove-files corresponding to
the selected modules are deleted from the compiled Compose file. This
allows for a much greater control when overwriting compose sequences
without relying on certain behaviour of the parsing applications (Does
the first or the last occurence count?). Moreover, we can now delete
prefixes of sequences we want to use.

The resulting Compose will be whitespace-normalized (whitespace outside
of quoted words will be replaced by a single space), stripped of keysyms
and comments, sorted and deduplicated.

Signed-off-by: hrnz <ulli@hrnz.li>
This commit is contained in:
hrnz 2021-02-06 23:30:58 +01:00
parent 1647be25d1
commit 7f4cce426a
2 changed files with 41 additions and 20 deletions

View File

@ -6,7 +6,7 @@
#
SRC = ./src
PSEUDO_MODULES_FILES = $(SRC)/enUS.module
MODULES_FILES = $(PSEUDO_MODULES_FILES) $(wildcard $(SRC)/*.module)
MODULES_FILES = $(PSEUDO_MODULES_FILES) $(wildcard $(SRC)/*.module) $(wildcard $(SRC)/*.remove)
# Gewünschte Build-Reihenfolge der Module. Die in den Listen
# genannten Dateien werden (falls Module dieses Namens existieren) in
@ -25,17 +25,6 @@ MODULES += $(foreach i, $(MODULE_ORDER_TAIL), $(findstring $(i),$(M)))
$(if $(findstring _,$(M)), \
$(error Unterstrich in Dateinamen $(SRC)/*.module nicht erlaubt))
# Liste von Demofiles, werden bei 'make all' erzeugt.
# Im Grunde ist dies seit 'make config' überflüssig.
#
DEMOFILES = \
XCompose_enUS_base \
XCompose_enUS_base_math \
XCompose_enUS_base_math_greek_lang \
XCompose_enUS_base_greek_lang \
XCompose_enUS_base_roman \
XCompose_enUS_base_math_greek_lang_cyrillic
# Hilfsprogramme
#
CHECKCOMPOSE = ./check-compose.pl
@ -46,13 +35,13 @@ CONFIGURE = /bin/bash ./configure.sh
# Defaultwert, falls .config noch nicht existiert.
#
-include $(wildcard .config)
USER_XCOMPOSE ?= XCompose_enUS_base_math
USER_XCOMPOSE ?= XCompose_enUS_base_cyrillic_diacritics_lang_greek_math_math-font
#
# 'make' bzw. 'make all' erzeugt die Datei XCompose ohne Installation
#
all : XCompose $(DEMOFILES)
all : XCompose
#
# 'make config' führt interaktive Abfrage der Konfiguration durch
@ -68,14 +57,28 @@ config : $(PSEUDO_MODULES_FILES) .config
#
# 'make XCompose_foo_bar_baz' erzeugt Datei aus Modulen foo bar baz
#
XCompose_% : $(MODULES_FILES)
#
XCompose_% : remove_% joined_%
# Entferne Zeilen aus remove_%
# Entferne Leerzeilen und Kommentarzeilen
# Entferne alles ab dem zweiten "
# Normalisiere Whitespace außerhalb von " "
# Sortiere und Entferne Duplikate
@echo "Erzeuge $@."
@echo "#" >$@
@echo "# Automatically generated file $@. Do not edit." >>$@
@echo "#" >>$@
@grep -Fvxf $^ | \
grep -v -e '^#' -e '^\s*$$' | \
perl -pe 's/(.*".*").*/\1/' | \
perl -pe 's{("[^"]*"|[^"\t ]+)|\s+}{$$1 // " "}ge' | \
sort -u > $@
joined_% : $(MODULES_FILES)
@echo "Erzeuge $@."
@echo "#" >$@
@echo "# Automatically generated file $@. Do not edit." >>$@
@echo "#" >>$@
@for i in \
`echo $@ | sed -e 's/XCompose//;s/_/ /g'` ;\
`echo $@ | sed -e 's/joined_//;s/_/ /g'` ;\
do \
fn=$(SRC)/$$i.module ;\
if [ -e $$fn ]; then \
@ -87,6 +90,20 @@ XCompose_% : $(MODULES_FILES)
fi \
done
remove_% : $(MODULES_FILES)
@echo "Erzeuge $@."
@echo "#" >$@
@echo "# Automatically generated file $@. Do not edit." >>$@
@echo "#" >>$@
@for i in \
`echo $@ | sed -e 's/remove_//;s/_/ /g'` ;\
do \
fn=$(SRC)/$$i.remove ;\
if [ -e $$fn ]; then \
cat $$fn >>$@ ;\
fi \
done
XCompose : $(USER_XCOMPOSE) $(wildcard .config)
cp $< $@

View File

@ -11,6 +11,10 @@ src/*.module
Enthält die Quelldateien für verschiedene Module der Compose-Datei.
Die Gliederung ist thematisch.
src/*.remove
Enthält Konflikte mit anderen Modulen. Der Inhalt dieser Dateien wird beim
Laden des entsprechenden Moduls gelöscht.
Makefile
Erstellt aus den Modulen eine oder mehrere lauffähige
XCompose-Dateien.