I have written the following function to shorten a string:
(defun shorten-hash () "Shorten string (forward or backwards) to eight characters; particularly for shortening hashes" (interactive) (let* ((bounds (bounds-of-thing-at-point 'word)) (word (if bounds (buffer-substring (car bounds) (cdr bounds)) nil)) (substring (if (and word (>= (- (cdr bounds) (car bounds)) 7)) (substring word 0 8) nil))) (if substring (progn (delete-region (car bounds) (cdr bounds)) (insert substring)) (message "Cannot shorten word to eight characters")))) (global-set-key (kbd "C-c M-f") 'shorten-hash) However, I would like to modify this to work with two key bindings, C-c M-f and C-c M-f, which works in the same way that M-BKSP vs M-d works. That is, C-c M-f will shorten the word after the cursor, and C-c M-b shortens the word before the cursor.