From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lorenzo Isella" Newsgroups: gmane.emacs.help Subject: Problem with keybindings Date: Fri, 14 Nov 2008 12:57:34 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226663888 15827 80.91.229.12 (14 Nov 2008 11:58:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Nov 2008 11:58:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 14 12:59:09 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L0xKL-0003z0-H5 for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Nov 2008 12:59:06 +0100 Original-Received: from localhost ([127.0.0.1]:58985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0xJD-0005IB-HV for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Nov 2008 06:57:55 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0xIv-0005I6-R6 for help-gnu-emacs@gnu.org; Fri, 14 Nov 2008 06:57:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0xIu-0005Hu-CQ for help-gnu-emacs@gnu.org; Fri, 14 Nov 2008 06:57:36 -0500 Original-Received: from [199.232.76.173] (port=47384 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0xIu-0005Hr-6w for help-gnu-emacs@gnu.org; Fri, 14 Nov 2008 06:57:36 -0500 Original-Received: from fg-out-1718.google.com ([72.14.220.159]:7851) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L0xIt-0006Hv-RV for help-gnu-emacs@gnu.org; Fri, 14 Nov 2008 06:57:36 -0500 Original-Received: by fg-out-1718.google.com with SMTP id l26so1209169fgb.30 for ; Fri, 14 Nov 2008 03:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:content-transfer-encoding :content-disposition:x-google-sender-auth; bh=5J7G3AK9ztMHFs2Y/MJiDADv6L0+I+/T4niMohsKCQ0=; b=D34LPiewc/Q0mKskJeVZ4VDhc/aSNUg+G/OOeveeKHWnI/aO9e3v4l4QF35Jm6OONJ YSGRGMtULcPIV5U6c3eb0zm0TpzJRZ37t764WxtXMRhuus7hojeGViJLJN1+90uHEtQt FJKDULfvaK+fj9vcIsjrBXdcRHOHex4Xpg7Vc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition:x-google-sender-auth; b=J2woaZILgC3F5JNqbE37utc6POqKmJv4ZpcJ2XQkm1Gcsysw1mpQjbZFlnTiBg98Bm D/cw85Sg/9JGyVFtNi8Z/dVETYRC9JsOnMsXTgnaki6nMHJI62nrRY7QEn3AfcqJ4B0J RvfQKWQwF69EGjRGF+2MX3g69peM0tJB97fgQ= Original-Received: by 10.187.242.9 with SMTP id u9mr100979far.96.1226663854564; Fri, 14 Nov 2008 03:57:34 -0800 (PST) Original-Received: by 10.187.167.2 with HTTP; Fri, 14 Nov 2008 03:57:34 -0800 (PST) Content-Disposition: inline X-Google-Sender-Auth: d82b82dbfd89d0e6 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59772 Archived-At: Dear All, I am trying to add a few hooks to my latex mode, but I must be doing something wrong. I should say that I am not a elisp programmer, I mainly catch some bits on the net and try to twist them according to my needs. Here are the functions (defun latex-surround-by (empty beg end back-over-end) "The main function implementing electric special characters ($, ^,_, etc.; see for example `latex-subscript'). If region is active, insert BEG before it and END after. Otherwise, insert EMPTY and place point BACK-OVER-END characters before the end of EMPTY. If `zmacs-regions' is nil, always behave as if region is *not* active." (if (and zmacs-regions (region-active-p)) (let ((text (buffer-substring (mark) (point)))) (delete-region (mark) (point)) (insert beg) (insert text) (insert end)) (progn (insert empty) (backward-char back-over-end)))) (defun latex-subscript () "Electric subscript. If region is not active, inserts \"_{}\" and places cursor between braces. Otherwise, inserts \"_{\" before region and \"}\" after. Basically, just a call to `latex-surround-by' with appropriate arguments." (interactive) (latex-surround-by "_{}" "_{" "}" 1)) (defun latex-superscript () "Electric superscript. If region is not active, inserts \"^{}\" and places cursor between braces. Otherwise, inserts \"^{\" before region and \"}\" after. Basically, just a call to `latex-surround-by' with appropriate arguments." (interactive) (latex-surround-by "^{}" "^{" "}" 1)) ;; LaTeX sectioning search. (defun latex-next-section () "Moves cursor to the nearest sectioning command below point." (interactive) (unless (search-forward-regexp "\\(\\\\\\(sub\\)*section\\)\\|\\(\\\\chapter\\)" nil t) (error "No more sectioning commands below."))) (defun latex-previous-section () "Moves cursor to the nearest sectioning command above point." (interactive) (unless (search-backward-regexp "\\(\\\\\\(sub\\)*section\\)\\|\\(\\\\chapter\\)" nil t) (error "No more sectioning commands above."))) and this is how I bind them ;; The actual bindings: (defun my-latex-bindings () (define-key LaTeX-mode-map [_] 'latex-subscript) (define-key LaTeX-mode-map [^] 'latex-superscript) (define-key LaTeX-mode-map [(control down)] 'latex-next-section) (define-key LaTeX-mode-map [(control up)] 'latex-previous-section) ) ;; Now I really activate the bindings (add-hook 'LaTeX-mode-hook 'my-latex-bindings) However, the function to jump to the previous/next section is correctly bound, but ^ and _ do not insert e.g. _{}. Can anyone give me a hint? I looked into my .emacs file and I do not believe I am re-binding e.g. ^ to anything else. Many thanks Lorenzo