Search Results

Search found 103 results on 5 pages for 'elisp'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • Elisp performance on Windows and Linux

    - by JasonFruit
    I have the following dead simple elisp functions; the first removes the fill breaks from the current paragraph, and the second loops through the current document applying the first to each paragraph in turn, in effect removing all single line-breaks from the document. It runs fast on my low-spec Puppy Linux box using emacs 22.3 (10 seconds for 600 pages of Thomas Aquinas), but when I go to a powerful Windows XP machine with emacs 21.3, it takes almost an hour to do the same document. What can I do to make it run as well on the Windows machine with emacs 21.3? (defun remove-line-breaks () "Remove line endings in a paragraph." (interactive) (let ((fill-column 90002000)) (fill-paragraph nil))) : (defun remove-all-line-breaks () "Remove all single line-breaks in a document" (interactive) (while (not (= (point) (buffer-end 1))) (remove-line-breaks) (next-line 1))) Forgive my poor elisp; I'm having great fun learning Lisp and starting to use the power of emacs, but I'm new to it yet.

    Read the article

  • Change nil's to zeroes in elisp

    - by mageslayer
    Hi all I'd like to ask - what is the function doing nil conversion from nil's to zeroes in elisp? I'm a newbie and I think I am inventing the wheel with my code: (defun chgnull (x) (if (null x) 0 1)) (mapcar 'chgnull '(1 2 nil)) Search through Emacs sources by keyword "to zero" and such haven't shown anything relevant.

    Read the article

  • elisp: call command on current file

    - by Jasie
    Hello, I want to set a key in emacs to perform a shell command on the file in the buffer, and revert the buffer without prompting. The shell command is: p4 edit 'currentfilename.ext' (global-set-key [\C-E] (funcall 'revert-buffer 1 1 1)) ;; my attempt above to call revert-buffer with a non-nil ;; argument (ignoring the shell command for now) -- get an init error: ;; Error in init file: error: "Buffer does not seem to be associated with any file" Completely new to elisp. From the emacs manual, here is the definition of revert-buffer: Command: revert-buffer &optional ignore-auto noconfirm preserve-modes Thanks!

    Read the article

  • Manipulating columns of numbers in elisp

    - by ~unutbu
    I have text files with tables like this: Investment advisory and related fees receivable (161,570 ) (71,739 ) (73,135 ) Net purchases of trading investments (93,261 ) (30,701 ) (11,018 ) Other receivables 61,216 (10,352 ) (69,313 ) Restricted cash 20,658 (20,658 ) - Other current assets (39,643 ) 14,752 64 Other non-current assets 71,896 (26,639 ) (26,330 ) Since these are accounting numbers, parenthesized numbers indicate negative numbers. Dashes represent 0 or no number. I'd like to be able to mark a rectangular region such as third column above, call a function (format-column), and automatically have (-73135-11018-69313+64-26330)/1000 sitting in my kill-ring. Even better would be -73.135-11.018-69.313+0.064-26.330 but I couldn't figure out a way to transform 64 -- 0.064. This is what I've come up with: (defun format-column () "format accounting numbers in a rectangular column. format-column puts the result in the kill-ring" (interactive) (let ((p (point)) (m (mark)) ) (copy-rectangle-to-register 0 (min m p) (max m p) nil) (with-temp-buffer (insert-register 0) (goto-char (point-min)) (while (search-forward "-" nil t) (replace-match "" nil t)) (goto-char (point-min)) (while (search-forward "," nil t) (replace-match "" nil t)) (goto-char (point-min)) (while (search-forward ")" nil t) (replace-match "" nil t)) (goto-char (point-min)) (while (search-forward "(" nil t) (replace-match "-" nil t) (just-one-space) (delete-backward-char 1) ) (goto-char (point-min)) (while (search-forward "\n" nil t) (replace-match " " nil t)) (goto-char (point-min)) (kill-new (mapconcat 'identity (split-string (buffer-substring (point-min) (point-max))) "+")) (kill-region (point-min) (point-max)) (insert "(") (yank 2) (goto-char (point-min)) (while (search-forward "+-" nil t) (replace-match "-" nil t)) (goto-char (point-max)) (insert ")/1000") (kill-region (point-min) (point-max)) ) ) ) (global-set-key "\C-c\C-f" 'format-column) Although it seems to work, I'm sure this function is poorly coded. The repetitive calls to goto-char, search-forward, and replace-match and the switching from buffer to string and back to buffer seems ugly and inelegant. My entire approach may be wrong-headed, but I don't know enough elisp to make this more beautiful. Do you see a better way to write format-column, and/or could you make suggestions on how to improve this code?

    Read the article

  • elisp compile, add a regexp to error detection

    - by Gauthier
    I am starting with emacs, and don't know much elisp. Nearly nothing, really. I want to use ack as a replacement of grep. These are the instructions I followed to use ack from within emacs: http://www.rooijan.za.net/?q=ack_el Now I don't like the output format that is used in this el file, I would like the output to be that of ack --group. So I changed: (read-string "Ack arguments: " "-i" nil "-i" nil) to: (read-string "Ack arguments: " "-i --group" nil "-i --group" nil) So far so good. But this made me lose the ability to click-press_enter on the rows of the output buffer. In the original behaviour, compile-mode was used to be able to jump to the selected line. I figured I should add a regexp to the ack-mode. The ack-mode is defined like this: (define-compilation-mode ack-mode "Ack" "Specialization of compilation-mode for use with ack." nil) and I want to add the regexp [0-9]+: to be detected as an error too, since it is what every row of the output bugger includes (line number). I've tried to modify the define-compilation-modeabove to add the regexp, but I failed miserably. How can I make the output buffer of ack let me click on its rows? --- EDIT, I tried also: --- (defvar ack-regexp-alist '(("[0-9]+:" 2 3)) "Alist that specifies how to match rows in ack output.") (setq compilation-error-regexp-alist (append compilation-error-regexp-alist ack-regexp-alist)) I stole that somewhere and tried to adapt to my needs. No luck.

    Read the article

  • emacs elisp buffer not running font lock mode until opened by user

    - by jacob
    My problem is I am opening a buffer using (set-buffer (find-tag-noselect (current-word))) and then I try to copy some text out of that buffer. The text that I get back has only the properties (fontified nil). find-tag-noselect automatically opens the buffer found in the TAGS file but it seems it does not run the font lock mode over it. When I manually switch to this buffer after it has been opened and then run the function again when it copies the text it has all the correct text properties attached. So what do I need to do to have this buffer completely initialized so that the correct syntax highlighting will be copied in?

    Read the article

  • Is there such a thing as an "elisp bundle" for TextMate?

    - by Vivi
    I started using Code Collector Pro to organise and save my Emacs codes, and this software requires TextMate bundles for syntax highlighting. They have a lisp bundle, but not an elisp bundle, at least not that I can see. I would think that the syntax highlighting would work under the lisp bundle, but for some reason it isn't happening. I have never even seen any lisp code with syntax highlighting, so it is possible that the thing is working and I don't know, but I honestly don't think so, because the ;; before a line seems to me to be a comment thing, so anything after that should be in the color defined for comments which in my case is green. Here is a picture of my code collector screen with a piece of code written by huaiyuan answering my question posted here: Is this looking as it should or is there something wrong? Back to the initial question: is there a textmate bundle for elisp or a bundle like the ones from textmate I can download to get syntax highlighting?

    Read the article

  • In elisp is there a difference between the regex [\\]documentclass and \\documentclass?

    - by mcheema
    I was playing around with the rx function for generating regular expressions from sexps in ELISP but couldn't figure out how to generate the regular expression "\\documentclass" for use in org-export-latex-classes: (rx "\\documentclass") (rx "\\" "documentclass") (rx (char "\\") "documentclass") Which when evaluated give respectively the following outputs: "\\\\documentclass" "\\\\documentclass" "[\\]documentclass" Is "\\documentclass" equivalent to "[\\]documentclass"?---I think it is, but am not sure. Can I generate the former using rx? Edit: Whilst the question was valid I realize my motivation was not; because org-export-latex-classes use strings not regular expressions.

    Read the article

  • elisp newbie question: Can't find 'filename' function definition in org.el?

    - by Dave Paroulek
    I really love org-mode in emacs and want to customize a few things. While reading thru org.el, I'm finding several references to filename but can't find filename using describe-function? I'm sure there's a simple answer, but I'm just learning elisp and it's not obvious. Any insight into where filename is defined? And/or if it's not a function, what is it? For example, filename on line 25502: (filename (if to-buffer (expand-file-name (concat (file-name-sans-extension (or (and subtree-p (org-entry-get (region-beginning) "EXPORT_FILE_NAME" t)) (file-name-nondirectory buffer-file-name))) "." html-extension) (file-name-as-directory (or pub-dir (org-export-directory :html opt-plist))))))

    Read the article

  • How to replace "(" with "\(" in the regexp, Emacs/elisp flavor?

    - by polyglot
    Question as title. More specifically, I'm rather tired of having to type \(, etc. every time I want a parenthesis in Emacs's (interactive) regexp functions (not to mention the \\( in code). So I wrote something like (defadvice query-replace-regexp (before my-query-replace-regexp activate) (ad-set-arg 0 (replace-regexp-in-string "(" "\\\\(" (ad-get-arg 0))) (ad-set-arg 0 (replace-regexp-in-string ")" "\\\\)" (ad-get-arg 0))))) in hope that I can conveniently forget about emacs's idiosyncrasy in regexp during "interaction mode". Except I cannot get the regexp right... (replace-regexp-in-string "(" "\\\\(" "(abc") gives \\(abc instead of the wanted \(abc. Other variations on the number of slashes just gives errors. Thoughts? Since I started questioning, might as well ask another one: since lisp code is not supposed to use interactive functions, advicing query-replace-regexp should be okay, am I correct?

    Read the article

  • How can I tweak this elisp function to distinguish between C-d & DEL?

    - by Fletcher Moore
    Here's my current function (blindly copy-pasted from a website) (defun tweakemacs-delete-one-line () "Delete current line." (interactive) (beginning-of-line) (kill-line) (kill-line)) (global-set-key (kbd "C-d") 'tweakemacs-delete-one-line) There are two quirks here that I want to get rid of. 1) This actually rebinds DEL to the same function. I want my DEL to remain "delete one character". 2) There needs to be a condition where it will not double-kill if the line is only a newline character.

    Read the article

  • Emacs eshell over SSH not obeying key commands or elisp

    - by Brad Wright
    When SSHing to a remote server Eshell doesn't behave very well, e.g: M-x eshell ssh server <tab> *inserts literal tab instead of trying to complete* Hitting <tab>, for instance, inserts a literal tab. Is there no way to get tab completion, lisp interaction (like find-file blah) etc. over SSH? All the documentation I've read says Eshell is "TRAMP-aware", which I assume meant it could deal with this. Am I just wrong in my assumption that it would work over SSH, or is something broken? This is on Emacs 24.0.94 pretest.

    Read the article

  • elisp macro to write function?

    - by aaa
    hello I have written few functions, which nearly identical, save for names. For example ; x is name, such as function/paragraph/line/etc. (defun my-x-function (interactive) (mark-x) (do-more-stuff) (modify-x)) is there a way to put it automatically? I have a feeling this is what macros do, but I am not sure how to use them. you help/maybe small example would be great Thanks

    Read the article

  • How to make emacs properly indent if-then-else construct in elisp

    - by Mad Wombat
    When I indent if-then-else construct in emacs lisp, the else block doesn't indent properly. What I get is: (defun swank-clojure-decygwinify (path) "Convert path from CYGWIN UNIX style to Windows style" (if (swank-clojure-cygwin) (replace-regexp-in-string "\n" "" (shell-command-to-string (concat "cygpath -w " path))) (path))) where else form is not indented at the same level as the then form. Is there an obvious way to fix this?

    Read the article

  • How can I emulate Vim's * search in GNU Emacs?

    - by rq
    In Vim the * key in normal mode searches for the word under the cursor. In GNU Emacs the closest native equivalent would be: C-s C-w But that isn't quite the same. It opens up the incremental search mini buffer and copies from the cursor in the current buffer to the end of the word. In Vim you'd search for the whole word, even if you are in the middle of the word when you press *. I've cooked up a bit of elisp to do something similar: (defun find-word-under-cursor (arg) (interactive "p") (if (looking-at "\\<") () (re-search-backward "\\<" (point-min))) (isearch-forward)) That trots backwards to the start of the word before firing up isearch. I've bound it to C-+, which is easy to type on my keyboard and similar to *, so when I type C-+ C-w it copies from the start of the word to the search mini-buffer. However, this still isn't perfect. Ideally it would regexp search for "\<" word "\>" to not show partial matches (searching for the word "bar" shouldn't match "foobar", just "bar" on its own). I tried using search-forward-regexp and concat'ing \ but this doesn't wrap in the file, doesn't highlight matches and is generally pretty lame. An isearch-* function seems the best bet, but these don't behave well when scripted. Any ideas? Can anyone offer any improvements to the bit of elisp? Or is there some other way that I've overlooked?

    Read the article

  • How do I get Emacs to evaluate a file when a frame is raised?

    - by Brad Wright
    Basically I have my Emacs set up so it has a GUI specific elisp, but when starting it in daemon mode this doesn't evaluate. The code is something like: ;; gui.el (when window-system (progn ;; do stuff here )) I'd like this file (or at least the code within it—perhaps a funtion) to be re-evaluated when I run emacsclient -c on the command line, as I miss out on all my font-lock and color-theme goodness (as I have that stuff set to runonly when a GUI exists).

    Read the article

  • Implementing a continuous "revert-buffer" aka Textpad

    - by vedang
    One of my colleagues uses TextPad, and one feature I found really useful is the Auto-Reload. (The feature has been described in this SO quesion: http://stackoverflow.com/questions/1246083/alternative-to-textpads-prompt-to-reload-file). Basically, it keeps reloading the file without any prompt from the user, which is really helpful when monitoring log files that are updated in real-time. Is there something similar available for Emacs? If not, can anyone whip up the required elisp magic?

    Read the article

  • Accessing StackExchange API from Emacs

    - by cschol
    I am trying to access the StackExchange API from Emacs' elisp: (require 'url) (require 'json) (defvar url-http-end-of-headers) (defun read-json () (interactive) (with-current-buffer (url-retrieve-synchronously "http://api.stackoverflow.com/0.8/users/2386") (goto-char url-http-end-of-headers) (json-read))) M-x read-json results in the following error: JSON readtable error. Am I missing anything?

    Read the article

  • How can I execute a SQL query in emacs lisp?

    - by Chris R
    I want to execute an SQL query and get its result in elisp: (let ((results (do-sql-query "SELECT * FROM a_table"))) (do-something-with results)) I'm using Postgres, and I already know all of my connection information (host, username, password, db et al) I just want to execute the query and get the result back, synchronously.

    Read the article

  • Emacs How to redefine Shift-R for expected use

    - by John Bellone
    I've checked my elisp files to make sure that I do not have any bindings that contain Shift+R (and I have not found any). I expect SHIFT+R to print an uppercase character, but instead I get R R undefined inside of the Emacs command line. This is only in C/C++ major modes. Any suggestions? Update: Describing the key shows that it is undefined. How would I define it for the normal, expected use (capitalizing the letter R)?

    Read the article

  • Emacs align-regexp on = but not ==

    - by Karl
    I am working in Haskell and frequently come across code similar to the following: func i j | i == j = i | otherwise = j I want to align on the '=' character using align-regexp but don't have the elisp knowhow. I have tried just doing " = " without the quotes, but this inserts an unwanted space character before each '='. I have found a proposed solution here but I can't seem to get that to do anything at all. Please help me write a function or hard-coded macro that will allow me to set a keybinding for this.

    Read the article

  • emacs, unsplit a particular window split

    - by kindahero
    this may be stupid question, but I could not find direct solution to this. I often want to unsplit window as follows +--------------+-------------+ +--------------+-------------+ | | | | | | | | | | | | | | | | | | +--------------+ | --> | | | | | | | | | | | | | | | | | | | | | +--------------+-------------+ +--------------+-------------+ +--------------+--------------+ +-----------------------------+ | | | | | | | | | | | | | | | +--------------+--------------+ --> +-----------------------------+ | | | | | | | | | | | | +-----------------------------+ +-----------------------------+ currently, I start with ctrl-x 1 and then split vertically/horizontally. but my real qustion is how can one remove a particular window split with out disturbing the other window structure.? is there any elisp function in built.? hope I frame my question correctly

    Read the article

  • Emacs: annoying Flymake dialog box.

    - by baol
    Hello I have the following lines in my ~/.emacs.d/init.el (custom-set-variables '(flymake-allowed-file-name-masks (quote ( ("\\.cc\\'" flymake-simple-make-init) ("\\.cpp\\'" flymake-simple-make-init))))) (add-hook 'find-file-hook 'flymake-find-file-hook) When I open a cc/cpp file that has a Makefile with the following content in the same folder I get proper on-the-fly compilation and error reporting (Flymake will check the syntax and report errors and warnings during code editing) .PHONY: check-syntax check-syntax: $(CXX) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES) The problem is that when I open a .cc file that has no corresponding Makefile i get an annoying dialog box that warns me about flymake being disabled for every file opened. Is there some hook I can use to disable that warning? Can you provide sample elisp code and explanation on how you found the proper hook?

    Read the article

1 2 3 4 5  | Next Page >