;;
;;; Version:
-(defconst lj-version 1.26
+(defconst lj-version 1.27
"Version number of SXEmacs/LJ.")
;;; Code:
\\{lj-mode-map}"
:group 'lj
:syntax-table nil
- :abbrev-table 'lj-abbrev-table
- (auto-save-mode 1))
+ :abbrev-table lj-abbrev-table
+ (auto-save-mode 1)
+ (abbrev-mode 1))
(add-hook 'lj-mode-hook #'font-lock-mode)
(set-process-sentinel proc #'lj-twitter-sentinel))
(warn "LJ subject too long for Twitter"))))
+(defun lj-check-limits (bodlen sublen taglen muslen loclen)
+ "Make sure we don't exceed any LJ size limits.
+
+Argument BODLEN: length of the body of a post. Max is 65535 bytes.
+Argument SUBLEN: length of the subject header. Max is 100 chars.
+Argument TAGLEN: length of the tags header. Max is 100 chars.
+Argument MUSLEN: length of the music header. Max is 100 chars.
+Argument LOCLEN: length of the location header. Max is 100 chars."
+ (let ((maxbod 65535)
+ (maxsub 100)
+ (maxtag 100)
+ (maxmus 100)
+ (maxloc 100))
+ (and (> bodlen maxbod)
+ (error 'invalid-argument
+ (format "Post body exceeds maximum by %d chars"
+ (- bodlen maxbod))))
+ (and (> sublen maxsub)
+ (error 'invalid-argument
+ (format "Subject exceeds maximum by %d chars"
+ (- sublen maxsub))))
+ (and (> taglen maxtag)
+ (error 'invalid-argument
+ (format "Tags exceed maximum by %d chars"
+ (- taglen maxtag))))
+ (and (> muslen maxmus)
+ (error 'invalid-argument
+ (format "Music header exceeds maximum by %d chars"
+ (- muslen maxmus))))
+ (and (> loclen maxloc)
+ (error 'invalid-argument
+ (format "Location header exceeds maximum by %d chars"
+ (- loclen maxloc))))))
+
(defun lj-post (&optional out-of-order)
"Submit a new post to LiveJournal.
((eq (car current-prefix-arg) 16)
(setq date (lj-set-date/time)
backdated t)))
+ (lj-check-limits (length body)
+ (length subject)
+ (length tags)
+ (length music)
+ (length location))
(setq url (lj-construct-url subject body user security tags comm nil nil
mood location music pickw date backdated))
;; lets save the draft out to disc just in case something goes wrong