validationemacselispiban

On-the-fly bank account numbers verification


Today I had to copy a bank account number from a real (dead tree) letter to an Emacs buffer and then send it by email. And I made a mistake while copying it from the letter to the Emacs buffer (forgot one digit). Which resulted in one email from a coworker telling me: "couldn't make the payment, bogus IBAN".

How hard would it be to create a function/minor-mode that would:

Ideally I'd need a minor-mode that I could turn on for several types of buffers (silly text files, but also email, etc.).

What would be the "approach" to use to do that using Emacs?


Solution

  • You can easily use something like

    (font-lock-add-keywords nil
      '(("[A-Z][A-Z][0-9]\\{x,y\\}"
         (0 (if (eq (mod blabla 97) foo) nil 'font-lock-warning-face))))))
    

    Just fill in the blabla.