Checking bank account numbers on the fly

Today I had to copy the bank account number from a real (dead tree) letter into the Emacs buffer, and then send it by email. And I made a mistake by copying it from the letter to the Emacs buffer (forgot one digit). This led one co-author employee to tell me: "Failed to make payment, fictitious IBAN."

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

  • detect "things" that look like IBAN (for example, two uppercase letters followed by the numbers "x" and "y", ignoring spaces, etc. There are ready-to-use regular expressions that check if something looks like IBAN or not)

  • run mod 97 and highlight IBAN in red if it looks invalid

Ideally, I need a secondary mode that I could enable for several types of buffers (stupid text files, but also email, etc.).

What will be the β€œapproach” that you can use to use Emacs?

+6
source share
1 answer

You can easily use something like

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

Just fill in blabla.

+9
source

Source: https://habr.com/ru/post/915303/


All Articles