;; Better C-a (defun weechat-beginning-of-message (&optional arg) "Go to the beginning of the message, or the start of the prompt, if after. If point is before the beginning of the message or the prompt on the input line, then go to the beginning of the line as `beginning-of-line'. /me lines are supported. This is as `weechat-bol', but also stops after the date and the author." (interactive "P") (let ((point (point)) (message-regexp (rx line-start digit digit ?: digit digit ?: digit digit " " ; time stamp (or ;; Join/part/system messages (sequence (or "-->" "<--" "--" "=!=" "!!!" "===") (1+ blank)) ;; User names (sequence (optional (char ?@ ?& ?% ?+ ?: ?~)) ; User prefix (1+ alphanumeric) ; The real user name ?: (0+ " ")) ;; Completely blank lines (for the Weechat buffer) (eval `(repeat ,(- weechat-text-column (length "00:00:00 ")) " "))))) (/me-line-regexp (rx line-start digit digit ?: digit digit ?: digit digit " " ; time stamp " " (group ?*)))) (save-match-data (forward-line 0) (cond (arg) ((<= weechat-prompt-end-marker point) ; At input line after prompt (goto-char weechat-prompt-end-marker)) ((<= weechat-prompt-start-marker point)) ; At input line before or in prompt ((and (looking-at message-regexp) ; A message line (<= (match-end 0) point)) ; at or after ; the beginning of the message (goto-char (max (+ (point) weechat-text-column) (match-end 0)))) ((and (looking-at /me-line-regexp) ; A /me line (<= (match-beginning 1) point)) ; at or after ; the beginning of the message (goto-char (match-beginning 1))) (t)))))