<commit_before># This macro is to remove 1 character form selected line on the left.
# Useful to clean code copied from diff file.
#
# Author: <NAME> (<EMAIL>)

from xpcom import components
viewSvc = components.classes["@activestate.com/koViewService;1"]\
    .getService(components.interfaces.koIViewService)
view = viewSvc.currentView
view = view.queryInterface(components.interfaces.koIScintillaView)
sm = view.scimoz

# Make `start` the beginning position of the first selected line,
# and `end` the ending position of the last selected line.
if sm.anchor < sm.currentPos:
    start = sm.positionFromLine(sm.lineFromPosition(sm.anchor))
    end = sm.getLineEndPosition(sm.lineFromPosition(sm.currentPos))
else:
    start = sm.positionFromLine(sm.lineFromPosition(sm.currentPos))
    end = sm.getLineEndPosition(sm.lineFromPosition(sm.anchor))

lines = tuple(sm.getTextRange(start, end).splitlines())
# Cut one character from the left
lines = tuple(l[1:] for l in lines)

# Select part of document
sm.setSel(start, end)
# Replace selection content
sm.replaceSel('\n'.join(lines))

<commit_msg>Improve Left_pare: Keep selection after applying.<commit_after># This macro is to remove 1 character form selected line on the left.
# Useful to clean code copied from diff file.
#
# Author: <NAME> (<EMAIL>)

from xpcom import components
viewSvc = components.classes["@activestate.com/koViewService;1"]\
    .getService(components.interfaces.koIViewService)
view = viewSvc.currentView
view = view.queryInterface(components.interfaces.koIScintillaView)
sm = view.scimoz

# Make `start` the beginning position of the first selected line,
# and `end` the ending position of the last selected line.
if sm.anchor < sm.currentPos:
    start = sm.positionFromLine(sm.lineFromPosition(sm.anchor))
    end = sm.getLineEndPosition(sm.lineFromPosition(sm.currentPos))
else:
    start = sm.positionFromLine(sm.lineFromPosition(sm.currentPos))
    end = sm.getLineEndPosition(sm.lineFromPosition(sm.anchor))

lines = tuple(sm.getTextRange(start, end).splitlines())
# Cut one character from the left
lines = tuple(l[1:] for l in lines)

# Select part of document
sm.setSel(start, end)
# Replace selection content
text = '\n'.join(lines)
sm.replaceSel(text)
# Keep selection to allow to continue to apply this macro if use wants
sm.setSel(start, start+len(text))

{'fraction_non_alphanumeric': 0.10622866894197952, 'fraction_numerical': 0.002559726962457338, 'mean_word_length': 5.270053475935829, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1295187', 'n_tokens_mistral': 732, 'n_tokens_neox': 719, 'n_words': 212}