Press "Enter" to skip to content

5 search results for "emacs"


GNU EmacsFor typesetting mathematics, I am used to use the LaTeX document preparation system with the AUCTeX package for the GNU Emacs editor, and the GNOME Evince viewer, provided by Debian. Here is my modest init file: dot-emacs.el. It features synctex forward and inverse search (without focus problems) and many other goodies. Feel free to use it and to improve it!

Wikipedia provides a rich list of LaTeX editors. By curiosity, you may try from time to time some of these editors. Even if they have made huge progresses, I still believe personally that Emacs is the best to date, due to its versatility: within the editor, one can open a remote file using SSH, one can search for bibtex entries from arXiv or MathSciNet, one can play with Octave, etc.

PS: EMACSulation is the name of an old series of articles by Eric Marsden in the Linux Gazette.

;;; Djalil's GNU Emacs .emacs.el init file, dated 2013-05. 
;;; Tested with Emacs 23 and 24, Auctex 11.86, Evince 3.4
;;; With Auctex 11.87, reverse/forward search is almost built-in (with bugs)
;;; Debian: apt-get install wmctrl auctex preview-latex 
(add-to-list 'load-path "~/S/elisp")
(setq custom-file "~/")
(setq locale-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(set-default-font "DejaVu Sans Mono-16")
(require 'jka-compr) ; Read compressed files
(require 'paren)     ; Visual matching () {} [] 
;; s-region.el and pc-select are obsolete.
;;  They are superseded by shift-select-mode enabled by default in 23.1.
;(require 's-region)  ; Copy/Cut/Paste with Shift/Delete/Insert
(put 'eval-expression 'disabled nil)
(put 'erase-buffer 'disabled nil)
(put 'narrow-to-region 'disabled nil)
 '(column-number-mode t)
 '(default-major-mode 'text-mode)
 '(delete-selection-mode t)
 '(dired-listing-switches "-alF")
 '(dired-ls-program "/bin/ls")
 '(fill-column 78)
 '(global-font-lock-mode t)
 '(indent-tabs-mode nil)
 '(iso-accents-customize french)
 '(line-number-mode t)
 '(resize-minibuffer-mode t)
 '(search-highlight t)
 '(sentence-end-double-space nil)
 '(show-paren-mode t)
 '(show-paren-ring-bell-on-mismatch t)
 '(show-paren-style 'mixed)
 '(tab-width 4)
 '(tool-bar-mode nil)
 '(transient-mark-mode t)
;;; I don't remember who wrote this useful function...
(defun match-paren (arg)
  " Go to the matching parenthesis if on parenthesis otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
        ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
        (t (self-insert-command (or arg 1)))))
;;; Keys
(define-key global-map [(%)] 'match-paren)
(define-key global-map [(f1)] 'help)
(define-key global-map [(f2)] 'run-octave)
(define-key global-map [(f3)] 'font-lock-mode)
(define-key global-map [(f4)] 'ispell-change-dictionary)
(define-key global-map [(next)] '(lambda ()(interactive)(scroll-up 25)))
(define-key global-map [(prior)] '(lambda ()(interactive)(scroll-down 25)))
(define-key global-map [(control home)] 'beginning-of-buffer)
(define-key global-map [(control end)] 'end-of-buffer)
(define-key global-map [(meta backspace)] 'undo)
(define-key global-map [(meta return)] 'eshell)
;(define-key global-map [(delete)] 'delete-char)
;;; Bibretrieve allows to fetch Bibtex entries from MathSciNet or arXiv
;;; Get if from
(autoload 'bibretrieve "bibretrieve" "Search for BibTeX entries on the web" t) 
(setq bibretrieve-backends '(("mrl" . 10) ("arxiv" . 5)))
;;; LaTeX: AUCTeX, Bibcite, RefTeX, etc
(require 'tex-site)
(load-library "auctex")
(load-library "preview-latex") 
(load "server")
(unless (server-running-p) (server-start))
(if window-system (require 'font-latex))
(autoload 'turn-on-bib-cite "bib-cite")
 '(TeX-auto-save t)
 '(TeX-master nil)
 '(TeX-parse-self t)
 '(TeX-source-specials-mode t)
 '(bib-cite-use-reftex-view-crossref t)
 '(reftex-enable-partial-scans t)
 '(reftex-insert-label-flags (quote (t t)))
 '(reftex-plug-into-AUCTeX t)
 '(reftex-save-parse-info t)
   (quote (("thm" ?h "th:" "~\\ref{%s}" nil ("thm" "th.")) 
           ("defn" ?d "def:" "~\\ref{%s}" nil ("defn" "def.")) 
           ("lem" ?l "lem:" "~\\ref{%s}" t ("lem" "lem.")))))
 '(reftex-use-multiple-selection-buffers t))
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(add-hook 'LaTeX-mode-hook 'turn-on-bib-cite)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(add-hook 'LaTeX-mode-hook 'font-lock-mode)
(add-hook 'LaTeX-mode-hook 'imenu-add-menubar-index)
(add-hook 'LaTeX-mode-hook 'my-LaTeX-keys)
(defun my-LaTeX-keys ()
  (define-key LaTeX-mode-map [down-mouse-3] 'imenu)
  (define-key LaTeX-mode-map [(f7)] 'preview-buffer)
  (define-key LaTeX-mode-map [(f8)] 'preview-clearout-buffer)
  (define-key LaTeX-mode-map [(f9)] 'TeX-command-master)
  (define-key LaTeX-mode-map [(f10)] 'TeX-next-error)
  (define-key LaTeX-mode-map [(f12)] 'TeX-toggle-debug-bad-boxes)
  (define-key LaTeX-mode-map [(print)] 'preview-buffer)
  (define-key LaTeX-mode-map [(control B)] 'bibretrieve)
  (define-key LaTeX-mode-map [(control C)] 'reftex-citation)
  (define-key LaTeX-mode-map [(control R)] 'reftex-reference))
(add-hook 'server-switch-hook 'raise-frame)
;; Forward/inverse search using Evince (based on dbus, needs also wmctrl)
;; Forward: C-c C-v 
;; Inverse: Ctrl - Left Mouse Button
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode)
(setq TeX-source-correlate-method 'synctex) ; instead of source-specials 
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
;; Forward search.
(defun un-urlify (fname-or-url)
  "Transform file:///absolute/path into /absolute/path"
  ;; Limited support for special characters"
  (if (string= (substring fname-or-url 0 8) "file:///")
      (url-unhex-string (substring fname-or-url 7))
(defun urlify-escape-only (path)
  "Handle special characters for urlify"
  (replace-regexp-in-string " " "%20" path))
(defun urlify (absolute-path)
  "Transform /absolute/path to file:///absolute/path"
  ;; Limited support for special characters"
   (concat "file://" 
            (concat default-directory absolute-path)))))
(if (require 'dbus "dbus" t) 
      ;; universal time, need by evince
      (defun utime ()  
        (let ((high (nth 0 (current-time)))
              (low (nth 1 (current-time))))
          (+ (* high (lsh 1 16) ) low)))
      (defun auctex-evince-forward-sync (pdffile texfile line)
        (let ((dbus-name
                "org.gnome.evince.Daemon"  ; service
                "/org/gnome/evince/Daemon" ; path
                "org.gnome.evince.Daemon"  ; interface
                (urlify pdffile)
                t ; Open a new win if file not opened.
           (urlify-escape-only texfile)
           (list :struct :int32 line :int32 1)
        ;DC: bring the window to the foreground and give it the focus 
        (call-process "wmctrl" nil nil nil "-R" pdffile)) 
      (defun auctex-evince-view ()
        (let ((pdffile (concat (TeX-master-file TeX-output-extension)))
              (texfile (buffer-file-name))
              (line (line-number-at-pos)))
          (auctex-evince-forward-sync pdffile texfile line)))
      ;; New view entry: Evince via D-bus.
      (setq TeX-view-program-list '())
      (add-to-list 'TeX-view-program-list
                   '("EvinceDbus" auctex-evince-view))
      ;; Prepend Evince via D-bus to program selection list
      ;; overriding other settings for PDF viewing.
      (setq TeX-view-program-selection '())
      (add-to-list 'TeX-view-program-selection
                   '(output-pdf "EvinceDbus"))))
;; Inverse search.
(if (require 'dbus "dbus" t) 
      (defadvice raise-frame (after make-it-work (&optional frame) activate)
        "Work around some bug? in raise-frame/Emacs/GTK/Metacity/something.
         Katsumi Yamaoka"
         "wmctrl" nil nil nil "-i" "-R"
         (frame-parameter (or frame (selected-frame)) 'outer-window-id)))
      (defun auctex-evince-inverse-sync (file linecol timestamp)
        (let ((buf (get-file-buffer (un-urlify file)))
              (line (car linecol))
              (col (cadr linecol)))
          (if (null buf)
              (message "Sorry, %s is not opened..." file)
            (switch-to-buffer buf)
            (goto-line (car linecol))
            (unless (= col -1)
              (move-to-column col))
;;; Tramp 
(require 'tramp)
(setq tramp-default-method "scp")
;;; Octave mode
(autoload 'octave-mode "octave-mod" nil t)
(setq auto-mode-alist
      (cons '("\\.m$" . octave-mode) auto-mode-alist))
(add-hook 'octave-mode-hook
          (lambda ()
            (abbrev-mode 1)
            (auto-fill-mode 1)
            (if (eq window-system 'x)
                (font-lock-mode 1))))
(add-hook 'inferior-octave-mode-hook
          (lambda ()
            (define-key inferior-octave-mode-map [up]
            (define-key inferior-octave-mode-map [down]
;; Credits
;;; EOF.
1 Comment

The Julia Language

The Julia Language

I played a bit this spring with Julia (the software, not the girl next door ;-). For Debian : apt-get install julia julia-doc. This was the source of great enthusiasm! Julia is a promising software for scientific computing. Yet another interpreter around Lapack? Yes and no. Some people believe that Julia is a revolution in scientific computing. For most of my daily needs, Julia is already almost preferable to Matlab/Octave/Scilab/R/C++/Python/… due to multiple bleeding edge technical features, including a high performance just-in-time compiler. Julia is flexible like Matlab, is fast like C, is free software like Octave/Scilab/R (MIT license), is text friendly like Python, and much more. Julia is also good for its competitors: it will help them to evolve. The reading of «Why we created Julia» by the creators of Julia is informative. An impressive summary of Julia features is given on, which provides many resources, including videos featuring the great Alan Edelman (MIT group leader, co-creator of Julia).

Learning Julia is a pretty easy task. Here is one of my first Julia program:

Pkg.add("Winston") # Pkg.add("Winston") is needed once for all.
using Winston # for simple graphics à la Matlab
n = 1000;
(D,U) = eig((randn(n,n)+im*randn(n,n))/sqrt(2*n));
I = [-1:.01:1]; J = sqrt(1-I.^2);
title(@sprintf("Complex Ginibre Ensemble %dx%d",n,n))

(this is one of my standard tests: Ginibre ensemble!) which produces the following image: Ginibre with JuliaJulia is still young – born in 2012, version 0.2 – and needs time to gain maturity, notably for plotting support among other things. One can regret the lack of a graphical user interface, but one can use Emacs+ESS, or the wonderful IPython notebooks in web browser via the Julia package IJulia. For Debian: apt-get install ess ipython-notebook. Give it a try!



LaTeX editors under Linux

Latex balloonRecently, a friend of mine, who is also a mathematician, received a new laptop equipped with Ubuntu, a version of the Linux operating system based on Debian. He asked then about the best available free LaTeX editor under Linux. There is no canonical answer to this question. I like to use Emacs and sometimes vim (old Unix habits). Many other editors have a LaTeX plugin such as gedit, geany, jedit, etc. There is also a bunch of LaTeX specific editors such as texworks, latexila, texmaker, kile, etc. For people not so familiar with Unix,  I suggest to try gummi (for people familiar with Apple Macs) or texstudio (for people familiar with Microsoft Windows). People familiar with Scientific Workplace or Scientific Word may try lyx. This software universe is evolving so rapidly that this post will become obsolete very soon.

I take this opportunity to advertise xournal, written by the mathematician Denis Auroux. This program has nothing to do with LaTeX, but  is very useful : it allows to annotate PDF files!

Leave a Comment

Linux story

Linus Benedict Torvalds
Linus Torvalds, creator of Linux and Git, behind the official mascot of the Linux kernel, the penguin Tux.

The Internet takes its historical roots in US military and academic projects in the sixties. Its present popular success is due to the invention of the World Wide Web (WWW) by Tim Berners Lee around 1990, while working at the European organization for nuclear research (CERN) in Geneva. Many WWW servers are powered by Linux. Linux is a Unix-like operating system created in 1991 by Linus Torvalds in Helsinki (not named by him – see below). He also created later the distributed revision control system Git to help the development of the Linux kernel. The current Linux kernel, still controlled by Torvalds, is actually a huge collaborative project developed by a decentralized group of independent individuals spread across the world. Many of them are employed by corporates such as Intel, IBM, SGI, Oracle, RedHat, Google, Nokia, Samsung, paid to contribute to the kernel (a symptom of the great success of Linux in the Industry). Linux has reached the age of twenty this year. You may read the interesting text Linux at 20, some personal memories by Lars Wirzenius, a classmate of Linus Torvalds. Here are some excerpts:

“Linux is 20 years old this year. That’s a long time. Since I was there from the beginning I thought I’d share some memories of what’s happened. In 1988 I graduated from high school, and got accepted into the University of Helsinki to study computer science. […] That’s also where I met the only other Swedish speaking new CS student of that year, a guy named Linus Torvalds. […] Computers were quite expensive back then, and the university provided access to classrooms full of PCs running MS-DOS, plus a few Macs, and some terminals connected to a big VAX/VMS system. I never liked MS-DOS that much, and they were often all in use. I couldn’t make heads or tails of the couple of Macs I tried, never having seen a GUI before. Thus I naturally graduated to the terminals, even though VAX/VMS was a horrible system to use, I thought.  […] The CS department had a small Ultrix computer hidden away, mostly unused, and I happened to get access to that. Ultrix was DEC‘s version of Unix. I had read about Unix, particularly in the K&R C book, and liked what I’d read. […] Multiple processes at the same time! Filenames weren’t unnaturally constricted! It was quite liberating. […]

We explored the Unix system and related tech in other ways as well, and had great fun. […] Christmas 1990 came and went, and on January 5, Linus bought a new computer. He’d been using a Sinclair QL at home, but wanted a PC with an Intel 386 CPU. He took his student loan and bought one. He intended to learn about multitasking by learning how the 386 did it. Unfortunately, he also got a copy of Prince of Persia (I think it was), a computer game. […] Months later, when he finally got bored of the game, he started actually learning 386 programming. […] Second, I’d known Linus for a while now, and although he was clever, he was also lazy, and sometimes, when he was drunk, he’d start arguing about things and say some of the silliest, most stupid things one can imagine anyone saying. […] However, Linus kept playing with multitasking on his 386, and making it do more, piece by piece. […]

What Linus really wanted, though, was a Unix computer at home. He’d heard of Minix, and he’d bought the book, and got Minix running on his 386 PC. It worked, but nowhere near as well as the machines at the university. Thus he kept prodding Minix, and improving his own multitasking program, and generally hacking away. […] Linus’s multitasking program grew, and grew, and gained features such as a hard disk driver, and memory management, and a filesystem. He had enough of a kernel to run some userspace programs, and he made it so that he could compiler programs on Minix, and run them on his own kernel. […] In August, Linus mentioned his kernel project on comp.os.minix for the first time. Later on, he decided to make the code available, and got one of the admins of to put it there. For this, the project needed a name. Linus wanted to call it Freax, but Ari Lemmke, the admin, decided to call it Linux instead. You can find the Freax name in the Makefile of the earliest Linux releases. […] The first Linux release was not installable, as I recall. Linus needed to develop a way to install his operating system. […]

In 1993, both Linus and I got hired by the CS department as assistant teachers (possibly teaching assistant is the correct English term): we helped other students with their homework, and checked that they had done it. This meant that we got to share an office. This was quite good for Linux development. Linus had an income, so he didn’t have to worry about that, and more importantly, fast Internet access, which helped things quite a bit, especially since Linux was gaining networking abilities. […] For a while, Linux did not quite do everything right with networking, so it was banned from the university network. That gave Linus a lot of motivation to fix it, of course. […]

Fast Internet access also allowed Linus and me to have a look at the various Linux distributions that were popping up. For whatever reason, Linus picked Red Hat. I thought that the Force needed some balance, so I picked Debian. We’ve both stuck to our choices since.  The emergence of Linux distributions was, of course, a boon for Linux. Even if the systems were much harder to use than, say, Mac or Windows ones, at least it was no longer necessary to fiddle with hex editors to get it to install and boot. This made the user base much larger, and brought in a lot of new people, some of whom also participated in the development of the systems. […]

Being employed by the university also helped us when we decided to organize a launch event for Linux version 1.0, in 1994, when it finally happened. We got access to the auditorium, and the head of the CS department gave a speech, and all this gave us enough credibility that there was a fair bit of interest from mainstream media. There was even a television crew, and the footage is occasionally found in various places on the Internet. During the speeches, we had a ceremonial compilation of the 1.0 kernel running in the background. In 1997, Linus graduated and got hired by Transmeta, and moved to the US, and I mostly lost direct contact with him. […] Let’s hope Linux and free software are around for the next twenty years and help nurture the revolution further.”

Richard Matthew Stallman
Richard Stallman, creator of Copyleft, the Free Software Foundation, and the GNU Project including GCC and Emacs

Personally (the author of this blog) I use Linux since August 1996, thanks to my classmate Guillaume Foliard, who connected me with the ANRTT group in Toulouse, created by David Robert and few friends of him including Jean-Christophe Arnu, Marc Thirion, David Rocher, Emmanuel Chaput, and Patrick Magnaud, among others. I will remember for ever my first meeting with them, in salle Marnac of Ramonville Saint-Agne. To my knowledge, this group was one of the first Linux and Free Software users group in France. I was preparing my Diplôme d’Études Approfondies in Mathematics in 1996-1997, and to be honest, I devoted a great part of my time to the learning of Unix instead of doing Mathematics! I am very happy with Linux, both at home and at work. It suits perfectly a mathematician like me who likes intellectual freedom and computer science concepts. I tried first the Slackware distribution, and then switched quickly to RedHat for few years, and then to Debian ten years ago. I also tried a bit Mandrake, Ubuntu, and various other Linux distributions. I even tried by simple curiosity other Unix-like operating systems such as FreeBSD (now at the heart of Mac OS X). But nothing suits me like Debian (I should say Debian GNU/Linux). I am impressed by the strength, via Linux, of the fourty years old concepts of Unix, and by the GNU Project. I wonder if in the near future, a young guy will come with something completely new and revolutionary. Linux based operating systems are nowadays fully functional and easy to use, thanks to the development of Free Software such as X.Org, KDE, GNOME, LibreOffice, Firefox, Thunderbird, GIMP, etc. This development is impressive, and the differences with non-free operating systems and software are presently negligible. My 68 years old mother is now using Debian GNU/Linux daily. I do not see GNU/Linux  as a conceptual revolution. It is brilliant engineering work, sometimes innovative, always pragmatic. However, the ideas of Free Software developed by Richard Stallman were revolutionary at the social level. With Linux, this anarchy utopia of Stallman became massively concrete. Wikipedia is another implementation of the anarchy utopia of Stallman at the social level (powered by Linux and various other free software including GNU software, Apache, MySQL, and MediaWiki). To me, the success of free software is due to the absolute of Stallman and to the pragmatism of Torvalds.

Note: my first computer was also an Intel 386 (June 1992) and I loved 386 programming 🙂

Debian GNU/Linux: an analysis was performed for Debian GNU/Linux version 4.0 (2007). This distribution contained close to 283 million source lines of code (the Linux kernel represents few percents), and the study estimated that it would have required about seventy three thousand man-years and cost US$7.6 billion (in 2011 dollars) to develop by conventional means.

Unix: actually everybody is using a Unix like operating system everyday, for instance via smartphones (including the iPhone), and when using Internet since most DNS servers are powered by a Unix like operating system.

Advertisement: Debian Woman Project

People to know: Masatoshi Shima

Leave a Comment

Can't find what you're looking for? Try refining your search:

Syntax · Style · .