*** html-helper-mode.el.orig Fri Sep 26 00:00:00 1997 --- html-helper-mode.el Fri Sep 26 00:00:00 1997 *************** *** 628,633 **** --- 628,639 ---- (defvar html-helper-any-list-item-end "\\|\\|\\|\\|") (defvar html-helper-any-list-start "
\\|
\\|\\|\\|\\|\\|\\|\\|") + (defvar html-helper-any-preformated-start "
")
+ (defvar html-helper-any-preformated-end "
") + (defvar html-helper-any-preformated-list + (format "\\(%s\\)\\|\\(%s\\)" + html-helper-any-preformated-start + html-helper-any-preformated-end)) (defvar html-helper-any-list (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)" html-helper-any-list-start *************** *** 650,655 **** --- 656,678 ---- ((match-beginning 4) 'item-end) (t 'error))) + (defun html-helper-context-symbol-preformated () + "Return the symbol the last match (against `html-helper-any-preformated') found." + (cond ((match-beginning 1) 'pre-start) + ((match-beginning 2) 'pre-end) + (t 'error))) + + (defun html-helper-guess-preformated-block-context () + "Figure out the last preformated tag before point relavant to indentation. + Returns 'pre-start if the last tag is start pre-formated block. + 'pre-end if the last tag is end pre-formated block." + (save-excursion + (let* ((lim (max (point-min) (- (point) html-helper-search-limit))) + (context (if (re-search-backward html-helper-any-preformated-list lim t) + (html-helper-context-symbol-preformated) + nil))) + (cons context (current-indentation))))) + (defun html-helper-guess-prev-context () "Figure out the last list-type tag before point relevant to indentation. Returns 'item-start if the last list tag is a list item start *************** *** 673,678 **** --- 696,719 ---- (defvar html-helper-print-indent-info nil "If t, indent will print out information as a message.") + ;; + ;; check if current context is in pre-formated block + ;; + (defun html-helper-preformated-block-p () + "Figure out this line is in pre-formated block. + Returns t if this line is in pre-formated block. + nil if this line is not in pre-formated block." + (progn + (setq pre-block (html-helper-guess-preformated-block-context)) + (setq pre-context (car pre-block)) + (setq now-context nil) + (if (looking-at html-helper-any-preformated-list) + (progn + (setq now-context (html-helper-context-symbol-preformated)))) + (cond ((and (eq pre-context 'pre-start) + (eq now-context nil)) t) + (t nil)))) + (defun html-helper-indent-command () "Command for indenting HTML to the appropriate column. Calls `html-helper-indent' which tries to examine how many levels down *************** *** 684,689 **** --- 725,731 ---- ;; some ideas borrowed from cc-mode.el. ;; Basic logic: + ;; if this line is in pre-formated block, then do not indentation. ;; if this line is some sort of list token, indent according to prev context: ;; if previous context was a list-end or item-start, use its indentation ;; if previous context was a list start, indent forward basic-offset *************** *** 700,706 **** (defun html-helper-indent () "Indentation workhorse function." ! (if html-helper-never-indent () (let ((m (point-marker)) (bol (progn (beginning-of-line) (point)))) --- 742,748 ---- (defun html-helper-indent () "Indentation workhorse function." ! (if (or html-helper-never-indent (html-helper-preformated-block-p)) () (let ((m (point-marker)) (bol (progn (beginning-of-line) (point))))